1

After connecting a new external 5TB hard drive and formatting it as ext4 with parted and mkfs with the procedure below, I then mounted the drive, copied files onto it, unmounted the drive and restarted its host computer (running Ubuntu 18.04.3 LTS). Upon mounting the drive again, the files were no longer on the drive. What am I doing wrong?

  1. Got drive information using lshw:

    # sudo lshw -C disk
    *-disk
       description: ATA Disk
       product: ST2000LM015-2E81
       vendor: Seagate
       physical id: 0.0.0
       bus info: scsi@2:0.0.0
       logical name: /dev/sda
       version: SDM1
       serial: ZDZ5H230
       size: 1863GiB (2TB)
       capabilities: gpt-1.00 partitioned partitioned:gpt
       configuration: ansiversion=5 guid=2f8a9ef2-85cf-49fe-8cf6- 
       04d7caae1a08 logicalsectorsize=512 sectorsize=4096
    *-disk
       description: SCSI Disk
       product: Portable
       vendor: Seagate
       physical id: 0.0.0
       bus info: scsi@3:0.0.0
       logical name: /dev/sdb
       version: 9300
       serial: NAA5C9V7
       size: 4657GiB (5TB)
       capabilities: gpt-1.00 partitioned partitioned:gpt
       configuration: ansiversion=6 guid=bea19262-56ed-43c1-a4cd- 
       62bca45eeb62 logicalsectorsize=512 sectorsize=4096
    
  2. Implemented ext4 file system using parted:

    # sudo parted /dev/sdb
    
    GNU Parted 3.2
    Using /dev/sdb
    Welcome to GNU Parted! Type 'help' to view a list of commands.
    (parted) mklabel gpt
    Warning: The existing disk label on /dev/sdb will be destroyed and all data on this disk will be lost. Do you want to continue?
    Yes/No? Yes
    (parted) unit TB
    (parted) mkpart
    Partition name?  []? 5tb
    File system type?  [ext2]? ext4
    Start? 0
    End? 5
    (parted) print
    Model: Seagate Portable (scsi)
    Disk /dev/sdb: 5.00TB
    Sector size (logical/physical): 512B/4096B
    Partition Table: gpt
    Disk Flags:
    Number  Start   End     Size    File system  Name  Flags
     1      0.00TB  5.00TB  5.00TB  ext4         5tb
    
    (parted) quit
    Information: You may need to update /etc/fstab.
    
  3. Make or Build a Linux File System (use mkfs)

    # sudo mkfs -t ext4 /dev/sdb1
    mke2fs 1.44.1 (24-Mar-2018)
    /dev/sdb1 alignment is offset by 512 bytes.
    This may result in very poor performance, (re)-partitioning suggested.
    Creating filesystem with 1220933433 4k blocks and 152616960 inodes
    Filesystem UUID: e29ea500-1588-4128-9e12-b2f62891b318
    Superblock backups stored on blocks:
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
        4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
        102400000, 214990848, 512000000, 550731776, 644972544
    
    Allocating group tables: done
    Writing inode tables: done
    Creating journal (262144 blocks): done
    Writing superblocks and filesystem accounting information: done
    
  4. Manually mounted/unmount the Hard Drive using mount:

    Create a mount point:
    # sudo mkdir /media/5tb
    Manually mount the drive (not automatic at boot)
    # sudo mount /dev/sdb1 /media/5tb
    Unmount the drive
    # sudo umount /media/5tb
    

EXTENDED Sep 11, 2019:

Upon reboot, it appears the drives are "reversed" (ie the 5TB drive is now /dev/sda and the 2TB drive is now /dev/sdb):

root@nuc3:/media/5tb# sudo lshw -C disk
  *-disk
       description: SCSI Disk
       product: Portable
       vendor: Seagate
       physical id: 0.0.0
       bus info: scsi@0:0.0.0
       logical name: /dev/sda
       version: 9300
       serial: NAA5C9V7
       size: 4657GiB (5TB)
       capabilities: gpt-1.00 partitioned partitioned:gpt
       configuration: ansiversion=6 guid=657182bf-8953-4001-b0d0-4b81832b17e6 logicalsectorsize=512 sectorsize=4096
  *-disk
       description: ATA Disk
       product: ST2000LM015-2E81
       vendor: Seagate
       physical id: 0.0.0
       bus info: scsi@3:0.0.0
       logical name: /dev/sdb
       version: SDM1
       serial: ZDZ5H230
       size: 1863GiB (2TB)
       capabilities: gpt-1.00 partitioned partitioned:gpt
       configuration: ansiversion=5 guid=2f8a9ef2-85cf-49fe-8cf6-04d7caae1a08 logicalsectorsize=512 sectorsize=4096

@jos, I applied the fdisk to both drives:

# sudo fdisk -l /dev/sda
Disk /dev/sda: 4.6 TiB, 5000981077504 bytes, 9767541167 sectors
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: 657182BF-8953-4001-B0D0-4B81832B17E6

Device     Start        End    Sectors  Size Type
/dev/sda1  65535 9767533004 9767467470  4.6T Linux filesystem

Partition 1 does not start on physical sector boundary.
# sudo fdisk -l /dev/sdb
Disk /dev/sdb: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors
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: 2F8A9EF2-85CF-49FE-8CF6-04D7CAAE1A08

Device       Start        End    Sectors  Size Type
/dev/sdb1     2048    1050623    1048576  512M EFI System
/dev/sdb2  1050624 3907026943 3905976320  1.8T Linux filesystem
mook765
  • 15,925
  • See answers to this question – user68186 Sep 10 '19 at 22:39
  • Please add the output of sudo fdisk -l /dev/sdb to your question. How is the drive connected to the computer? Is the drive in an enclosure? – mook765 Sep 11 '19 at 01:13
  • The 5TB drive is an external USB drive connected with a USB cable to an Intel NUC that has an internal 2TB drive. – user1421347 Sep 11 '19 at 14:01
  • Upon reboot, it appears the drives are "reversed" (ie the 5TB drive is now /dev/sda and the 2TB drive is now /dev/sdb): – user1421347 Sep 11 '19 at 14:05
  • @jos, my modified post shows the details but your suggested sudo fdisk -l /dev/sda command informs that "Partition 1 does not start on physical sector boundary." – user1421347 Sep 11 '19 at 14:15
  • Not my suggestion, but @mook765 's: I merely edited the question for better layout. – Jos Sep 11 '19 at 14:28
  • Did the lost files end up on the other drive? – Jos Sep 11 '19 at 14:34
  • The partition doesn't look broken. That the partition does not start on a physical sector boundary is not good, but it doesn't explain the data loss. You should resize the partition unless you want to live with an impact on performance. Use Gparted instead of commandline-tools, it will take care for a correct alignment. How did you mount the partition, how did you copy the data to it, how did you unmount the partition? The mystery lies in the answer to these questions. – mook765 Sep 11 '19 at 14:52
  • Thanks so much for the reformat @mook765 - I could not figure that out.

    One clarification: this Intel NUC is running Ubuntu Server 18.04.3 LTS, not Desktop Ubuntu, so I will need to do everything on Terminal as Gparted is not available except on desktop GUI.

    – user1421347 Sep 11 '19 at 20:38
  • How should I resize the partition? I mounted the partition using the process in #4 above: Create a mount point with:

    sudo mkdir /media/5tb

    Then manually mount the drive (not automatic at boot):

    sudo mount /dev/sdb1 /media/5tb

    Once it was mounted, I copied a variety of data using the cp, mv and rsync commands. None of that data is there now, whereas it was before I rebooted Ubuntu. The commands were all in the format:

    cp filename /media/5tb/filename

    I manually unmounted the drive before rebooting Ubuntu.

    – user1421347 Sep 11 '19 at 20:38
  • @user1421347 I see, that's why you used parted. Maybe best to start over, remove the partition and create a new one. parted has --align-option which should be used, take a look at man parted. For your copied files, it's hard to say where they ended up, maybe you should look into the mount-point without the partition mounted to it. If you remember the names of some files you copied, make use of the find- or locate-command. – mook765 Sep 12 '19 at 01:41
  • Mind you: if you (1) create a mount point, (2) try to mount a disk there but fail, (3) move files there anyway, (4) successfully mount the disk, then your files will appear to be gone. They have simply been written to your root file system. You then need to unmount the disk to find your files. – Jos Sep 12 '19 at 08:04

0 Answers0