If you need to make further changes to fstab or move the mount point, be sure to unmount the device first: Test out your new drive by writing a file to it:Īlso try restarting the machine and ensure the drive automatically gets detected and mounted on boot. It's probably more useful to have it be owned by a specific user, so you'll want to recursively update its permissions: The hard disk mount folder is owned by root by default. This is why we executed sudo mount above. ![]() One of the defaults is nouser, meaning only a super user can mount drives. Here we use defaults, which defaults to a few common-sense options outlined in the documentation. The man fstab documentation outlines various configurable options. Open /etc/fstab file with root permissions: sudo vim /etc/fstabĪnd add following to the end of the file, substituting your own UUID and mount path: dev/sdb), it doesn't change if you move the drive to a new slot or machine in the future. We use the UUID because unlike device lables (e.g. Linux reads this file on each boot up and will automatically mount your new drive for you.įirst, find the drive's UUID. We'll edit this file to add an entry for your newly added hard drive. The /etc/fstab file contains a table of your filesystem devices. ![]() You don't want to have to manually mount your device each time you restart. The output shows that the new device partition /dev/sdb1 is mounted at /hdd. It can be any arbitrary pathįilesystem Size Used Avail Use% Mounted on Similar to device names, partitions under a device (drive) are named by sequentially numbering the device names:Ĭreate a mount point - this is the path where your new drive will be located. In this case primary is the name of the partition, not the partition type (which confusingly also uses the label primary). The partition table now has 1 partion equal to the size of the entire drive. mkpart primary ext4 0GB 500GB) in order to create multiple partitions if you'd like. Note that you can also choose to partition part of the disk or even certain ranges (e.g. Number Start End Size File system Name FlagsĪs you can see, it defaults to having no partitions (note the empty table at the bottom of the output). There are several partition table formats, but we'll be using gpt.Ĭreate a gpt partition table and verify the output: It's important you get the right device name - you don't want to format the wrong drive! You can always switch to a different selected drive by typing select /dev/sdX in the parted console.Ī partition table describes the layout of the partitions on a disk. Start the parted interactive console by giving it the device name you'd like to edit: The type is a two letter identifier based on the drive type, and the letter starts with a and increments sequentially: /dev/sda, /dev/sdb, etc. Linux drives are usually named in the format /dev/(type)(letter). Sector size (logical/physical): 512B/4096B Number Start End Size Type File system Flagsĥ 248GB 250GB 2011MB logical linux-swap(v1) Sector size (logical/physical): 512B/512B In this example I added a new 1TB Samsung SSD, which is named /dev/sdb. This time you'll notice a new drive, which may be labeled as unrecognized disk. Partition and Format the drive Locating the new DriveĪfter booting your machine back up, list your drives again. In this example I added a 1TB Samsung SSD (which also requires a 2.5" to 3.5" HDD adapter tray)Ģ. I personally recommend the HP Proliant line of home servers. This varies by make and model, but you should see hard drive slots to add new drives when you open up the casing. Next, you'll want to power down your machine and physically install the new hard drive. This is optional, but I like to use this "before" snapshot to compare it to the output we'll generate after installing the drive. Install the new hard drive (physically)īefore installing your new drive, grab a list of your current drives using parted.Whatever the reason, adding a new hard drive is a simple process that we can do straight from the command line. Maybe you're adding a second hard disk to store more media, or maybe you're installing a new SSD on your Linux homeserver. So you've got a new hard drive and you want to add it to your Linux machine.
0 Comments
Leave a Reply. |