[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Please check my sudo bash script



On 9/1/25 15:36, Tom Browder wrote:
On Mon, Sep 1, 2025 at 13:19 Tom Browder <tom.browder@gmail.com> wrote:
...

That info above is old. Since then I've used gparted.

Output from "lsblk":

  NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda      8:0    0   3.6T  0 disk
`-sda1   8:1    0   3.6T  0 part
sdb      8:16   0 465.8G  0 disk
|-sdb1   8:17   0   512M  0 part /boot/efi
|-sdb2   8:18   0 464.3G  0 part /
`-sdb3   8:19   0   976M  0 part [SWAP]
sdc      8:32   0 931.5G  0 disk
`-sdc1   8:33   0 931.5G  0 part
sdd      8:48   0 931.5G  0 disk
`-sdd1   8:49   0 931.5G  0 part

Output from "fdisk -l":

Disk /dev/sdc: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: CT1000MX500SSD1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: F14DE782-D810-485C-BE87-27CE5F0C57B0

Device     Start        End    Sectors   Size Type
/dev/sdc1   2048 1953523711 1953521664 931.5G Linux filesystem


Disk /dev/sda: 3.64 TiB, 4000787030016 bytes, 7814037168 sectors
Disk model: CT4000BX500SSD1
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: EC099B20-A54B-46F4-A025-E9A0A9EB5B88

Device     Start        End    Sectors  Size Type
/dev/sda1   2048 7814035455 7814033408  3.6T Linux filesystem


Disk /dev/sdb: 465.76 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Samsung SSD 870
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: 47F82EA1-CF17-4C3C-8804-A4BE63FC63D7

Device         Start       End   Sectors   Size Type
/dev/sdb1       2048   1050623   1048576   512M EFI System
/dev/sdb2    1050624 974772223 973721600 464.3G Linux filesystem
/dev/sdb3  974772224 976771071   1998848   976M Linux swap


Disk /dev/sdd: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: CT1000MX500SSD1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: 1DDE4FFD-9261-41B8-96D2-6EFBE9012B46

Device     Start        End    Sectors   Size Type
/dev/sdd1   2048 1953523711 1953521664 931.5G Linux filesystem

So, should I hand edit the /etc/fstab file (after saving a copy), and
try to get one new drive loaded and tested at a time as suggested
early on by David Christensen?

-Tom


The commands presented here are a "best guess", but are untested. Check the manual page for each command before you run it in case I have made errors. If any command produces an error message, cut and paste console session into a reply -- prompt, command entered, and output displayed.


The three SSD's look like they are partitioned and formatted. The next step is to decide where to mount the SSD file systems within the host file system.


Suppose you want to mount the 4 TB SSD file system at /backup.  Using a
root shell (denoted by the number sign prompt '#'), create the mount point in the host file system:

# mkdir /backup


Then run mount(8) to connect the 4 TB SSD file system into the host file system at the mount point:

# mount /dev/sda1 /backup


The 4 TB SSD file system should now be mounted into the host file system at /backup. Running mount(8) without any arguments or options will display all of the mounted file systems. /backup should be the last entry:

# mount


You can now put data onto the 4 TB SSD file system. Assuming your username and group are both "tom", create a directory under /backup for your computer and your home directory:

# mkdir -p "/backup/$HOSTNAME/$HOME"


Change the user and group owner of the created directory to your normal user account:

# chown tom:tom "/backup/$HOSTNAME/$HOME"


Now you can access the backup directory from your normal user account (denoted by the dollar sign prompt '$').


For example, you can use cp(1) to backup your music:

$ cp -rpv "$HOME/Music" "/backup/$HOSTNAME/$HOME/."


Later, after working on music, you can update the backup:

$ cp -rpuv "$HOME/Music" "/backup/$HOSTNAME/$HOME/."


When you are done using the 4 TB SSD file system, run umount(8) (note misspelling) in a root terminal to disconnect the 4 TB SSD file system from the host file system:

# umount /backup


If you want the 4 TB SSD file system to be mounted at /backup every time the computer boots, you can create an entry in /etc/fstab. Using a root terminal, make a backup copy of /etc/fstab. I like to append a suffix that matches the date/ time on the file:

# ll /etc/fstab
-rw-r--r-- 1 root root 1501 2024-12-26 11:56:00 /etc/fstab

# cp -p /etc/fstab /etc/fstab-20241226-115600


Then use an editor to add a line to /etc/fstab for the 4 TB SSD partition 1. Beware that device nodes can change at boot, especially if you add, remove, or rearrange disk drives. It is safer to use the universally unique identifier (UUID) instead of the device node to identify the first partition on the 4 TB SSD.


Use blkid(8) to find the UUID of a device node:

2025-09-01 17:25:16 root@laalaa ~
# blkid /dev/sda1
/dev/sda1: LABEL="laalaa_boot" UUID="d83609f1-8369-0486-f937-b836938a72c7" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="93b26ac0-01"


Use the UUID in /etc/fstab:

# nano /etc/fstab

UUID= d83609f1-8369-0486-f937-b836938a72c7  /backup  ext4  defaults  0  2


Then restart. When you log in, /backup should be mounted. Verify by running mount(8) with no options:

$ mount


David


Reply to: