Skip to content

Instantly share code, notes, and snippets.

@TacoSteemers
Last active December 17, 2015 05:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TacoSteemers/5560959 to your computer and use it in GitHub Desktop.
Save TacoSteemers/5560959 to your computer and use it in GitHub Desktop.
Partitioning and mounting a disk on a Debian system
What is present?
$ fdisk -l
To edit the partitions on /dev/sdz:
$ fdisk /dev/sdz
Follow the instructions.
Remove the partitions you want to remove, create new ones in their place.
Make sure to verify and write.
Then, update the kernel:
$ partprobe /dev/sdz
Then, create the filesystem(s):
$ mkfs.ext4 /dev/sdz1
Then, mount:
$ mkdir /media/volz1
$ mount -t ext4 /dev/sdz1 /media/volz1
Add a line like the following to fstab to let it be automounted:
/dev/sdz1 /media/volz1 ext4 defaults 0 2 # 2 for quick fs check
@TacoSteemers
Copy link
Author

Some of these require administrator rights

@TacoSteemers
Copy link
Author

For disks larger than 2TB we need to use a GPT instead of msdos type table. fdisk doesn't support GPT. We use parted instead.
The following shows how to create one large partition on a 3TB disk:

# parted /dev/sdz
(parted) unit TB
(parted) mklabel gpt
(parted) mkpart

Now we follow the instructions, entering 0TB for 'start' and 3TB for 'end'. Thats it.
We print out the partition table to verify:

(parted) print

@TacoSteemers
Copy link
Author

Note on external disk drive carriers:
Not that you with some drive carriers you can not properly partition or format a large disk drive. It is possible that you will end up with a smaller partition than you had hoped for. If that is the case, you will have to mount it internally instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment