Disk space

Tasks:

  • fdisk is under /sbin

    Disk /dev/sda: 32 GiB, 34359738368 bytes, 67108864 sectors
    Disk model: QEMU HARDDISK   
    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: 0xd80d0738
    
    Device     Boot    Start      End  Sectors  Size Id Type
    /dev/sda1  *        2048 63578111 63576064 30.3G 83 Linux
    /dev/sda2       63580158 67106815  3526658  1.7G  f W95 Ext'd (LBA)
    /dev/sda5       63580160 67106815  3526656  1.7G 82 Linux swap / Solaris
    
    
    Disk /dev/sdb: 64 GiB, 68719476736 bytes, 134217728 sectors
    Disk model: QEMU HARDDISK   
    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/sdc: 2 TiB, 2199023255552 bytes, 4294967296 sectors
    Disk model: QEMU HARDDISK   
    Units: sectors of 1 * 512 = 512 bytes
    Sector size (logical/physical): 512 bytes / 512 bytes
    I/O size (minimum/optimal): 512 bytes / 512 bytes
    
    
  • /dev/sda and associated partitions are for system, seems like an ext4 format

    studen@labkey:~$ sudo file -sL /dev/sda*
    /dev/sda:  DOS/MBR boot sector
    /dev/sda1: Linux rev 1.0 ext4 filesystem data, UUID=7aa97821-8328-41bf-add1-199fde502af2 (needs journal recovery) (extents) (64bit) (large files) (huge files)
    
    
  • /dev/sdb is for database, needs partitioning

    studen@labkey:~$ sudo fdisk /dev/sdb
    Command (m for help): g
    Created a new GPT disklabel (GUID: CEB79293-AAAF-4E3B-AC17-D7D5C4030135).
    Command (m for help): n
    Partition number (1-128, default 1): 
    First sector (2048-134217694, default 2048): <Enter>
    Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-134217694, default 134215679): <Enter>
    
    Created a new partition 1 of type 'Linux filesystem' and of size 64 GiB.
    
    Command (m for help): w
    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Syncing disks.
    studen@labkey:~$ sudo fdisk /dev/sdb
    
    Welcome to fdisk (util-linux 2.41).
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    
    
    Command (m for help): p
    Disk /dev/sdb: 64 GiB, 68719476736 bytes, 134217728 sectors
    Disk model: QEMU HARDDISK   
    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: gpt
    Disk identifier: CEB79293-AAAF-4E3B-AC17-D7D5C4030135
    
    Device     Start       End   Sectors Size Type
    /dev/sdb1   2048 134215679 134213632  64G Linux filesystem
    
    Command (m for help): q
    studen@labkey:~$ sudo mkfs.ext4 /dev/sdb1
    mke2fs 1.47.2 (1-Jan-2025)
    Discarding device blocks: done                            
    Creating filesystem with 16776704 4k blocks and 4194304 inodes
    Filesystem UUID: 4296eee3-c46d-42f5-8d84-da8dc712e3d7
    Superblock backups stored on blocks: 
            32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
            4096000, 7962624, 11239424
    
    Allocating group tables: done                            
    Writing inode tables: done                            
    Creating journal (65536 blocks): done
    Writing superblocks and filesystem accounting information: done   
    studen@labkey:~$ sudo blkid
    /dev/sdb1: UUID="4296eee3-c46d-42f5-8d84-da8dc712e3d7" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="50081ae0-6c42-4de7-8010-7ce19fbdfbcd"
    /dev/sda5: UUID="f54d2ee3-8dee-4792-a2c7-b529c2889ecd" TYPE="swap" PARTUUID="d80d0738-05"
    /dev/sda1: UUID="7aa97821-8328-41bf-add1-199fde502af2" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="d80d0738-01"
    
    
  • mount it to /data0 by editing /etc/fstab:

    studen@labkey:~$ vi /etc/fstab
    #database disk (/dev/sdb1), 20250926
    UUID=4296eee3-c46d-42f5-8d84-da8dc712e3d7 /data0   ext4    defaults 0       2
    studen@labkey:~$ sudo mkdir /data0
    studen@labkey:~$ sudo mount -a
    studen@labkey:~$ sudo systemctl daemon-reload
    
    
  • /dev/sdc is for files/images, needs partitioning

    studen@labkey:~$ sudo fdisk /dev/sdc
    [...]
    Device does not contain a recognized partition table.
    The size of this disk is 2 TiB (2199023255552 bytes). DOS partition table format cannot be used on drives for volumes larger than 2199023255040 bytes for 512-byte sectors. Use GUID partition table format (GPT).
    
    Created a new DOS (MBR) disklabel with disk identifier 0xb95bd7d0.
    
    Command (m for help): g
    Created a new GPT disklabel (GUID: F9E0CF5C-25C6-4086-91D4-A36AEB8C67F8).
    
    Command (m for help): n
    Partition number (1-128, default 1): 
    First sector (2048-4294967262, default 2048): 
    Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-4294967262, default 4294965247): 
    
    Created a new partition 1 of type 'Linux filesystem' and of size 2 TiB.
    
    Command (m for help): w
    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Syncing disks.
    
    studen@labkey:~$ sudo fdisk /dev/sdc
    [...]
    
    Command (m for help): p
    Disk /dev/sdc: 2 TiB, 2199023255552 bytes, 4294967296 sectors
    Disk model: QEMU HARDDISK   
    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: gpt
    Disk identifier: F9E0CF5C-25C6-4086-91D4-A36AEB8C67F8
    
    Device     Start        End    Sectors Size Type
    /dev/sdc1   2048 4294965247 4294963200   2T Linux filesystem
    studen@labkey:~$ sudo mkfs.ext4 /dev/sdc1
    mke2fs 1.47.2 (1-Jan-2025)
    Discarding device blocks: done                            
    Creating filesystem with 536870400 4k blocks and 134217728 inodes
    Filesystem UUID: aeffcc3c-c7f5-4856-9f30-6a5b402b764f
    Superblock backups stored on blocks: 
            32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
            4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968, 
            102400000, 214990848, 512000000
    
    Allocating group tables: done                            
    Writing inode tables: done                            
    Creating journal (262144 blocks): done
    Writing superblocks and filesystem accounting information: done
    
    
  • mount /dev/sdc1 as /data1

    studen@labkey:~$ sudo blkid
    [...]
    /dev/sdc1: UUID="aeffcc3c-c7f5-4856-9f30-6a5b402b764f" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="390885ba-f0f8-4871-985d-245d327f559e"
    studen@labkey:~$ vi /etc/fstab
    #files disk (/dev/sdc1), 20250926
    UUID=aeffcc3c-c7f5-4856-9f30-6a5b402b764f /data1        ext4    defaults 0       2
    studen@labkey:~$ sudo mkdir /data1
    studen@labkey:~$ sudo mount -a
    studen@labkey:~$ sudo systemctl daemon-reload
    
    
  • final layout

    studen@labkey:~$ df -h
    Filesystem      Size  Used Avail Use% Mounted on
    udev            7.8G     0  7.8G   0% /dev
    tmpfs           1.6G  520K  1.6G   1% /run
    /dev/sda1        30G  1.2G   27G   5% /
    tmpfs           7.9G     0  7.9G   0% /dev/shm
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs           1.0M     0  1.0M   0% /run/credentials/systemd-journald.service
    tmpfs           7.9G     0  7.9G   0% /tmp
    tmpfs           1.0M     0  1.0M   0% /run/credentials/getty@tty1.service
    tmpfs           1.6G  8.0K  1.6G   1% /run/user/1002
    /dev/sdb1        63G  2.1M   60G   1% /data0
    /dev/sdc1       2.0T  2.1M  1.9T   1% /data1
    
    

Discussion