to dir howto: manage disks    rev 11 nov 2022

Assuming Ubuntu, and command-line, unless otherwise stated.

» mount disk: usb↓ sata↓ at boot↓ | rename↓ custom icon↓ sources↓

.......................................................
➽ Mounting disks

  $ sudo fdisk -l
  or 
  $ sudo df -h
  
  $ sudo mount ... 

  * How to mount a device in linux
      https://unix.stackexchange.com/questions/18925/how-to-mount-a-device-in-linux
      - command-line, Disks app.
      - shows many details, screenshots.
      2011-2019 / retr 22 oct 2020

  There's a gui app in ubuntu/linuxmint called Disks
      (probably in other debian-based distributions also)
      (probably something similar in other *-based distributions also)
    - Shows format, current mounting status etc. 
    - Can also use to create/delete/format partitions.
      https://unix.stackexchange.com/questions/18925/how-to-mount-a-device-in-linux#answer-280714
      may 2016 / retr 22 oct 2020
    

......................... 
* mount a usb drive:

#  "On most modern Linux distribution like Ubuntu USB drive will
#   auto mount when you insert it, but sometimes you may need to  
#   manually mount the drive."

# See what is currently mounted:
#   By default, the output will include all file systems 
*   including the virtual ones such as cgroup, sysfs, and others. 
$ mount
#    To display only certain file systems use the -t option.
$ mount -t ext4


# See device to get name (such as, /dev/sda1)
#   external usb will usually be /dev/sdb1, sdb2, etc.
$ sudo fdisk -l
  

# Make directory for Mounting
$ sudo mkdir /media/newhd

# Mount it
#   Don't need to specify filesystem type (with -t) for common types.
$ sudo mount /dev/sdb1 /media/newhd

# See the file system
$ sudo df -H

# Unmount it
#  GUI: right-click on disk icon in sidebar and 'safely remove'
#     (clicking the arrow thingie in file manager window didn't unmount it.)
#  Command line:
$ sudo umount <directory>
# or
$ sudo umount <device_name>

# If the file system is in use the umount command will fail to detach
# the file system. In those situations, you can use the fuser command
# to find out which processes are accessing the file system:
$ fuser -m DIRECTORY

......................... 
* mount SATA drive:

 * Whenever the drive is spinning, do not move it around. 
      Sudden jolts to a spinning set of platters can harm the drive. 
      Wait until the drive has fully spun down prior to moving it. 

 * Order of plug/unplug cables
      To connect:
        - 1st power - plug in to to drive, then plug in to power.
        - 2nd usb - plug in the drive, then plug in to computer.
      To disconnect:
        - 1st unmount - umount; right-click 'remove safely'; etc.
        - 2nd usb - unplug from computer.
        - 3rd power - unplug from power.
       https://superuser.com/questions/651734/how-to-properly-use-sata-to-usb-cable

 * Gory details and more links;
     https://serverfault.com/questions/690609/in-which-order-do-i-plug-the-sata-power-and-data-cables-for-hotplug


......................... 
* Automatic mount at boot:

$ sudo vi /etc/fstab

/dev/sdb1    /media/newhd       ext3    defaults     0        2
/dev/sdb1    /media/windowshd   vfat    defaults     0        2

# dunno if this will automatically mount after boot, when drive inserted?



....................................................... 
➽ Rename disk:

  1. After connecting the USB drive, 
       locate the device using fdisk command 
       sudo fdisk -l
       or other commands for listing USB:
       https://linuxopsys.com/topics/list-usb-devices-in-linux

  2. Unmount the device:
       sudo umount /dev/xxxn

  3. FAT 32 - mtools package
       Can't get this to work - 
         am just changing FAT32 names on windows  :)

       # check current label:
       $ sudo mlabel 

       # prepare to change the label:
       $ sudo mlabel -i /dev/xxxn -s ::

       # update mtools.conf file - add a line:
       drive p: file=""
       to:
       drive p: file="/dev/xxxn"
       # (p can be any letter).

       # now change the label - 11-char limit:
       $ sudo mlabel -i /dev/xxxn ::new_name

  or

  3. ext3/ext4 - e2fsprogs package
       # check current label:
       $ sudo e2label /dev/xxxn
       # change the label - 16-char limit:
       $ sudo e2label /dev/xxxn new_name

  * GUI method: the gparted utility

  https://linoxide.com/howto-change-volume-label-on-usb-drives-in-linux/
  https://help.ubuntu.com/community/RenameUSBDrive

....................................................... 
➽ Custom icon:

  custom icon for fat32 or ext3/4 disk:

    # edit this file in top of disk filesystem:
    autorun.inf
      [autorun]
      ICON=AUTORUN\FAVICON.ICO
    # put an .ico image in autorun folder in top of disk filesystem:
    autorun/favicon.ico
    # if file and/or folder don't exist, just make them.



.......................................................
➽ Sources:

  * good summary
      https://www.cyberciti.biz/faq/mount-drive-from-command-line-ubuntu-linux/

  * more detail
      https://linuxize.com/post/how-to-mount-and-unmount-file-systems-in-linux/



_______________________________________________________
begin 22 oct 2020
Category: disks
-- 0 --