User Tools

Site Tools


disk

This is an old revision of the document!


Disk, Partition, File System

Disk

A disk is a block device.

fdisk

Used to create partitions on a disk.

$ sudo fdisk -l # list partitions

Note: In addition to listing disks and partitions, fdisk also lists loop mounts. A loop mount looks like a disk but is in fact a file containing a file system, created by a snap package install.

df
$ df -T  # disk filesystem format type
du
$ du pub # number of blocks for all subdirectories, summary total at end
$ du -a pub # all files, as well as subdirectories
$ du -s pub # summary total only
$ du -h pub # human-readable number of bytes
$ du --exclude="*.txt" pub # shell pattern, not regexp
$ du -d 1 pub # depth, 0 is same as -s
$ du -a pub | sort -n -r | head -n 20 # find largest files

Mount

Use the mount command to attach (mount) file systems and removable devices such as USB flash drives at a particular mount point in the directory tree.

$ mount                          # with no parameters, list mounted filesystems
$ mount /dev/sda1 /media/john    # mount a partition device to a mount point
$ sudo mount /dev/sdb1 /mnt/media
$ unmount device_name
$ unmount mount_point
device name vs mount point

Both exist in the directory tree.

device name is /dev/sda1, for example.

Mount point is a directory which you create. For example:

  • /media/seagate
  • /mnt/stick128

Mount External USB Drive at Boot

$ lsusb        # list USB devices
$ sudo blkid   # list UUID of all block devices
# add line to /etc/fstab:
# UUID=4078159978158F32  /media/seagate  ntfs  auto,nosuid,nodev,nofail,x-gvfs-show  0  0 
$ sudo mount -a # test the changes to /etc/fstab. Error can cause boot failure.
$ sudo systemctl reboot

/dev/sda is a disk
/dev/sda1 is a partition on the disk

We mount partitions, not disks.

tar
$ tar -czvf name-of-archive.tar.gz /path/to/directory-or-file
$ tar -xvzf name-of-archive.tar.gz
disk.1611830776.txt.gz · Last modified: 2021/01/28 05:46 by 127.0.0.1

Except where otherwise noted, content on this wiki is licensed under the following license: Public Domain
Public Domain Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki