What is the method to mount and expand a disk in Linux?
In Linux systems, you can mount disks and expand them using the following methods:
- To confirm the partition and file system of a disk: use the command fdisk -l to view the disk’s partition information, and use the command df -h to check the file system usage.
- You can create a new partition by using tools like fdisk or parted if there are no available partitions on the disk.
- Format the new partition: Use the mkfs command to format the new partition into the desired file system format, such as ext4.
- Create a mount point: Use the mkdir command to create a directory as the mount point, for example /mnt/newdisk.
- Mount a new partition: Use the command `mount` to mount the new partition to the created mount point, for example `mount /dev/sdb1 /mnt/newdisk`.
- Validate the mount point: use the command df -h to verify if the mount was successful, and ensure that the new partition is mounted to the specified mount point.
- Automatic Mounting: To automatically mount a new partition during system startup, it is necessary to add a mounting information in the /etc/fstab file. You can use the command blkid to view the UUID of the new partition and add it to the /etc/fstab file.
- If the disk has been resized but the file system has not automatically resized, you can use the command “resize2fs” to expand the file system. For example, “resize2fs /dev/sdb1”.
The method above is a common way to expand disk storage by mounting, although the specific steps may vary slightly depending on the Linux distribution and file system used.