Add a new hard disk/partition
Published on: 5th Dec 2020
Updated on: 30th Jan 2022
Why
When you are running out of storage space or you want to have a partition to keep the backup, then, you will definitely need the following commands to mount the partition (in layman terms, we 'attach' additional hard disks to the server).
What should we do to connect the partition to the server
-
To view the partitions & hard disks,
sudo fdisk -l
-
To view the mount points,
sudo mount -l
-
To mount a partition to the OS,
sudo mount /dev/sdb1 /mnt
where
/dev/sdb1
is the partition and/mnt
is the access point for user. -
To unmount a partition,
sudo umount /mnt
Note: you may mount a partition into the user's home folder as well. But, this requires to create a physical directory before mounting the partition.
sudo mount /dev/sdb1 /home/user/mnt
where
mnt
must be a created before the mount command.Note:
mount
effect will live until the server restarts. To permanently mount the directory, you must edit the/etc/fstab
file. If the directory has blank space, replace it with\040
which will be interpreted as space character. -
To mount a directory (not a partition) into another directory (for another user). For example, in the FTP service, user A and user B would like to access the same directory located in a different partition/directory.
http://askubuntu.com/questions/205841/how-do-i-mount-a-folder-from-another-partition
-
Below is the config that I have added to fstab in our server where I'm mounting the "SourceCodes" directory into "/home/lhw/SourceCodes" so that I can access the source code in the different hard disk/partition.
UUID=2CFA4F8CFA4F516E /mnt/backup ntfs rw 0 0 UUID=3060658D60655B1C /mnt/backup2 ntfs rw 0 0 /mnt/backup/SourceCodes /home/lhw/SourceCodes none bind 0 0
-
To view hard disk/partition usage,
df -H
-
To view the usage in the directory, run the following command. (You have to install ncdu).
ncdu
-
To install
ncdu
,sudo apt install ncdu
References
Related posts
Jump to #UBUNTU blog
Author
Lau Hon Wan, software developer.