Skip to content

Instantly share code, notes, and snippets.

@fizzvr
Created October 8, 2015 15:30
Show Gist options
  • Save fizzvr/75cfb8ccc55114828c97 to your computer and use it in GitHub Desktop.
Save fizzvr/75cfb8ccc55114828c97 to your computer and use it in GitHub Desktop.
Formatear una unidad
Partition, format and mount
Your data disk will likely be /dev/sdb, you can list your disks with:
fdisk -l
Now that we know /dev/sdb is there we can run the following commands to format and mount :
# Make partition
sudo parted -s -a optimal /dev/sdb mklabel gpt -- mkpart primary ext4 1 '-1'
# Format to ext4
sudo mkfs -t ext4 /dev/sdb1
# Make data dir
sudo mkdir -p /data
# Mount
sudo mount /dev/sdb1 /data
# Get the disk's UUID
disk_uuid=$(sudo blkid /dev/sdb1 | perl -n -e'/UUID="([^\"]+)"/ && print $1')
# Add to /etc/fstab so it's mounted on (re)boot
echo <<EOF
UUID=${disk_uuid} /data auto rw,user,auto 0 0
EOF | sudo tee -a /etc/fstab
# Voila :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment