[SOLVED]STDR2000100/ST2000LM007 partition/format from shell

New to Debian (Or Linux in general)? Ask your questions here!

[SOLVED]STDR2000100/ST2000LM007 partition/format from shell

Postby 1byte » 2018-05-18 06:46

I have upgraded HDD setup on my headless OptiPlex9020M to
internal M-SATA M.2 SSD WDC_WDS120G1G0B that has running:
4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64 GNU/Linux and
internal SATA-0 HDD STDR2000100/ST2000LM007 to store multimedia on it.

I have formated HDD's before with gnome-disk-utility/gparted, but never from shell.


What I like to do is, create symlink to home dir /home/hts so
TVHeadEnd can record directly to SATA-0 HDD instead to SSD and the content of the SATA-0 Drive be available to miniDLNA.


At the moment the SATA-0 HDD has default NTFS file system, with msdos partition table,
the M-SATA SSD has gpt partition table with the usual 1=fat32,boot,esp 2=ext4, 3=linux-swap(v1)



Later on I would like to add 6x Seagate 4TB Portable External USB 3.0 STDR4000100 to store
on each "specific" files symlinked to directories:
/home/user/Video
/home/user/Video.Hi-Def
/home/user/Video.FAMILY
/home/user/Pictures.FAMILY
/home/user/Audio
/home/user/Audio.Hi-Res
So if I can get one liner to achieve the below that would be great:


So my question is, in order to get the SATA-0 HDD STDR2000100/ST2000LM007 to be be symlinked to /home/hts
I first need:
-unmount the drive
-delete the current "ntfs" file system and
-then delete partition table "msdos" and
-create "gpt" on the HDD and then
-create filesystem "ext4"
-format the partition with "ext4"?


I have done the following:


Checked if it is not mounted
Code: Select all
$ sudo blkid -o list
device                                                                                             fs_type         label            mount point                                                                                            UUID
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/dev/sda1                                                                                                                                  ntfs                    Seagate Backup Plus Drive (not mounted)                                                                                                                                 




Code: Select all
$ sudo parted /dev/sda print free
Model: ATA ST2000LM007-1R81 (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system  Flags
        32.3kB  1049kB  1016kB           Free Space
 1      1049kB  2000GB  2000GB  primary  ntfs         boot
        2000GB  2000GB  512B             Free Space




Code: Select all
$ sudo parted /dev/sda mklabel gpt
Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue?
Yes/No? Yes                                                               
Information: You may need to update /etc/fstab.






Code: Select all
[code]$ sudo parted /dev/sda rm 1
Information: You may need to update /etc/fstab.
[/code]



Code: Select all
$ sudo parted /dev/sda print         
Model: ATA ST2000LM007-1R81 (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start  End  Size  File system  Name  Flags


Code: Select all
$ sudo parted -a optimal /dev/sda mkpart primary 0% 100%
Information: You may need to update /etc/fstab.




And end up with this:
Code: Select all
$ sudo parted /dev/sda print
Model: ATA ST2000LM007-1R81 (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags:

Number  Start   End     Size    File system  Name     Flags
 1      1049kB  2000GB  2000GB  ntfs         primary




So I have then changed to msdos partition table and format it in one command, but that did not work:
Code: Select all
$ sudo parted /dev/sda mklabel msdos mkpart primary ext4 0% 100%
Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue?
parted: invalid token: mkpart                                             
Yes/No? Yes
Information: You may need to update /etc/fstab.



Than decided to use "fdisk" in desperation:
Code: Select all
$ sudo fdisk /dev/sda

Welcome to fdisk (util-linux 2.29.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): F

Unpartitioned space /dev/sda: 0 B, 0 bytes, 0 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes

Command (m for help): p
Disk /dev/sda: 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: dos
Disk identifier: 0x2d70aec4

Device     Boot Start        End    Sectors  Size Id Type
/dev/sda1        2048 3907028991 3907026944  1.8T 83 Linux

Command (m for help): d
Selected partition 1
Partition 1 has been deleted.

Command (m for help): p
Disk /dev/sda: 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: dos
Disk identifier: 0x2d70aec4

Command (m for help): n
Partition type
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): 0
Value out of range.
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p): 4
Value out of range.
   p   primary (0 primary, 0 extended, 4 free)
   e   extended (container for logical partitions)
Select (default p):

Using default response p.
Partition number (1-4, default 1):
First sector (2048-3907029167, default 2048):
Last sector, +sectors or +size{K,M,G,T,P} (2048-3907029167, default 3907029167):

Created a new partition 1 of type 'Linux' and of size 1.8 TiB.
Partition #1 contains a ntfs signature.

Do you want to remove the signature? [Y]es/[N]o: Y

The signature will be removed by a write command.

Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.


And removed the ntfs signature ...

But not sure what to do now ...
Last edited by 1byte on 2018-05-20 07:04, edited 1 time in total.
1byte
 
Posts: 49
Joined: 2017-07-16 06:51

Re: STDR2000100/ST2000LM007 partition/format from shell

Postby p.H » 2018-05-18 07:51

1byte wrote:I first need:
-unmount the drive

You mount/unmounts a filesystem, not a drive.
Unnecessary if the filesystem is not mounted.
1byte wrote:-delete the current "ntfs" file system and
-then delete partition table "msdos" and
-create "gpt" on the HDD and then

All useless.
1byte wrote:-create filesystem "ext4"
-format the partition with "ext4"?

That's the same operation. And the only one needed.
Code: Select all
mkfs.ext4 /dev/sda1


Create the directory that will be used as the mount point.
Add a line in /etc/fstab to mount the filesystem (by UUID or LABEL, not device name) on the mount point.
Mount the filesystem.
Create the symlinks.

1byte wrote:I have done the following:

Uselessly. So much wasted time...
All you may want to do with a partition editor is to change the partition type identifier from "NTFS" to "Linux filesystem". But that's purely cosmetic and optional.
p.H
 
Posts: 395
Joined: 2017-09-17 07:12

Re: STDR2000100/ST2000LM007 partition/format from shell

Postby 1byte » 2018-05-18 12:49

I see, this was status before I issued the "sudo mkfs.ext4 /dev/sda1"
So final check that partitioin is created
Code: Select all
$ sudo parted /dev/sda print free
Model: ATA ST2000LM007-1R81 (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system  Flags
        32.3kB  1049kB  1016kB           Free Space
 1      1049kB  2000GB  2000GB  primary
        2000GB  2000GB  90.1kB           Free Space




Code: Select all
$ sudo mkfs.ext4 /dev/sda1
mke2fs 1.43.4 (31-Jan-2017)
Creating filesystem with 488378368 4k blocks and 122101760 inodes
Filesystem UUID: b2 ... 73
Superblock backups stored on blocks:
   32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
   4096000, 7962624, 11239424, 20480000, 23887872, 71663616, 78675968,
   102400000, 214990848

Allocating group tables: done                           
Writing inode tables: done                           
Creating journal (262144 blocks): done
Writing superblocks and filesystem accounting information: done       



Code: Select all
$ sudo lsblk --fs --ascii
NAME   FSTYPE LABEL UUID                                 MOUNTPOINT
sda                                                     
`-sda1 ext4         a... - ... - ...- ...- ...1
sdb                                                     
|-sdb1 vfat         B ... - ...6                            /boot/efi
|-sdb2 ext4         c ... - ... - ... - ... - ... a /
`-sdb3 swap         3 ... - ... - ... - ... - ... 7 [SWAP]


Code: Select all
$ sudo parted /dev/sda print free
Model: ATA ST2000LM007-1R81 (scsi)
Disk /dev/sda: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system  Flags
        32.3kB  1049kB  1016kB           Free Space
 1      1049kB  2000GB  2000GB  primary  ext4
        2000GB  2000GB  90.1kB           Free Space

So this filesystem is ready to be used? Does it all look sound?
Would gpt partition table be better?


Is the filesystem label "name the disk" necessary? (gnome-disk-utility -> Edit Filesystem - Label)
How can I create one for that disk, if it is already have filesystem created on it from shell?

I have created one anyway with:
Code: Select all
sudo e2label /dev/sda1 2TB



Code: Select all
sudo lsblk --fs --ascii
sudo blkid -o list


Code: Select all
sudo nano /etc/fstab
# <file system>                      <mount point>      <type>  <options>         <dump>   <pass>
UUID=a... - ... - ...- ...- ...1                           /media/user/2TB      ext4   defaults         0      2



Code: Select all
sudo reboot
sudo chown -R user:user /media/user/2TB
1byte
 
Posts: 49
Joined: 2017-07-16 06:51

Re: STDR2000100/ST2000LM007 partition/format from shell

Postby p.H » 2018-05-18 14:19

1byte wrote:So this filesystem is ready to be used? Does it all look sound?

Yes.
1byte wrote:Would gpt partition table be better?

GPT provides some benefits, but most would be irrelevant for your use case.
- supports size up to 2 TiB -> your disk is only 2 TB
- supports more than 4 partitions without an extended partition -> you have only one partition
- supports partition UUID and label -> filesystem UUID and label are available with ext4

A label is not necessary. It can be useful for identification purpose, or you can use it in /etc/fstab instead of the UUID.
But a label is less likely to be as unique as a UUID, even less "2TB" which is short and common.

I recommend against mounting a fixed system-wide filesystem in /media, even more in /media/user.
According to FHS, /media contains mount points for removable media. /media/user contains mount points for removable media mounted by user "user", and may not be permanent.
p.H
 
Posts: 395
Joined: 2017-09-17 07:12

Re: STDR2000100/ST2000LM007 partition/format from shell

Postby 1byte » 2018-05-18 15:31

p.H wrote:
1byte wrote:So this filesystem is ready to be used? Does it all look sound?

Yes.

I recommend against mounting a fixed system-wide filesystem in /media, even more in /media/user.
According to FHS, /media contains mount points for removable media. /media/user contains mount points for removable media mounted by user "user", and may not be permanent.


Where would you recommend mounting the HDD? Looking here:
https://wiki.debian.org/FilesystemHierarchyStandard
/mnt/ = Temporarily mounted filesystems
/media/ = Mount points for removable media such as CD-ROMs (appeared in FHS-2.3)



So to convert the hdd file system to NTFS, I would backup all the files from it and simply umount the filesystem and execute:
sudo mkntfs [options] device [number-of-sectors]
sudo mkntfs -L HDDlabel /dev/sdx1

Or lets say ext4/ntfs to exFAT, umount the ext4/ntfs and:
sudo mkfs.exfat -n HDDlabel /dev/sdx1

Or even FAT16/32, umount the ext4/ntfs and:
sudo mkfs.vfat -F 16 /dev/sdx1
sudo mkfs.vfat -F 32 /dev/sdx1?
1byte
 
Posts: 49
Joined: 2017-07-16 06:51

Re: STDR2000100/ST2000LM007 partition/format from shell

Postby p.H » 2018-05-18 17:14

1byte wrote:Where would you recommend mounting the HDD?

Anywhere you like and it makes sense. Not in /mnt.

For example, what about /home/hts ? Why create a symlink pointing to somewhere else while you can mount the filesystem directly on that location ?

1byte wrote:So to convert the hdd file system to NTFS, I would (cut)

Yes, yes and yes.
Some operating systems may require that you also change the partition type identifier in the partition table to match the filesystem type. Linux does not care.
p.H
 
Posts: 395
Joined: 2017-09-17 07:12


Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 3 guests

fashionable