[Operation and maintenance] Linux hard disk space is insufficient, expand the hard disk, mount the directory, and mount it permanently

  1. Allocate disk
    Insert picture description here

  2. View hard drive mount

    fdisk -l
    root@desktop:/home/user1# fdisk -l
    Disk /dev/vda: 30 GiB, 32212254720 bytes, 62914560 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    Disklabel type: dos
    Disk identifier: 0x4f6e894a
    
    Device     Boot    Start      End  Sectors  Size Id Type
    /dev/vda1  *        2048 37750783 37748736   18G 83 Linux
    /dev/vda2       37750784 37752829     2046 1023K 83 Linux
    /dev/vda3       37752830 41940991  4188162    2G  5 Extended
    /dev/vda5       37752832 41940991  4188160    2G 82 Linux swap / Solaris
    
    
    Disk /dev/vdb: 1 GiB, 1073741824 bytes, 2097152 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    
    
    Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 sectors
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    
    
  3. Try to mount /dev/sda to /home_expand

    If errors are reported, view the current device being mounted file system type df -h -T,
    and then format the / dev / sda
    if the other hard drive is ext3, use the mkfs.ext3 /dev/sdaformat
    if the other hard drive is ext4, use the mkfs.ext4 /dev/sdaformat
    to mount again, mount /dev/sda /home_expand
    this time as a temporary mount.

  4. Change to mount a long-term, you need to vim /etc/fstabfile added to the end

    /dev/sda /home_expand ext4 defaults 1 2

Click to jump: If you don’t understand the content of fstab, be sure to look at the detailed fstab content

  1. At this point, the mounting is complete, you can tryreboot

Guess you like

Origin blog.csdn.net/qq_22227087/article/details/108054659