Page 1 of 1

[SOLVED] Is format necessary for USB disk?

PostPosted: Oct 9th, '15, 02:41
by DoubtingT
Hi,

Mageia 4 (preparation to move to Mageia 5).

A revision to my earlier, panicked, post.


I bought a 1TB USB portable disk for backup prior to upgrading installation as above. In MCC I set sdb1 as type ext4 and clicked on the format command (with a check for bad sectors). 6 hours later the progress bar had not moved. I tried to stop the process, but when I clicked on the close cross I got an error box telling me that drakdisk was not responding and asking me if I want to terminate the application. When I said 'yes', it just kept going.

In Ksysguard I saw entries for 'usb storage' and 'bad blocks', and they oscillated between 1to 2% cpu usage and 'disk sleep'.Drakdisk said 'process status: sleeping. Process is waiting for something to happen.'

Eventually, after what seemed like an age, the process shut down, so the closebox obviously worked. The process itself causing the delay, perhaps?

In MCC the disk is now shown as being ext4, but unformatted. Nonetheless, I can enter it in Home. Presumably I can write to it too?

Have I just wasted hours on this process? Is a format actually necessary for this type of disk, or is it sufficient to simply click on the 'Type' command?

Thanks.

Re: Is format necessary for USB disk?

PostPosted: Oct 9th, '15, 13:47
by filip
Hi, I never use "check for bad sectors" as discs are handling that by themselves. That way format was always within seconds on SSD and still within one minute on (admittedly smaller) hdd.

I think that format is essential as it writes filesystem structure to partition itself while type is written only in MBR and AFAIK to the superblock(s).

Re: Is format necessary for USB disk?

PostPosted: Oct 9th, '15, 14:13
by doktor5000
Format is necessary, unless the partiton was already formatted before and is usable.
Bad blocks check may take several hours, and it writes and reads every block to determine if it gives good results or should be marked defective.
Depending on the speed an the size of the drive, I'd say the scan will probably take 6 to 12 hours at least.

You can check if it's still running if you still see an badblocks process in ksysguard.

DoubtingT wrote:In Ksysguard I saw entries for 'usb storage' and 'bad blocks', and they oscillated between 1to 2% cpu usage and 'disk sleep'.Drakdisk said 'process status: sleeping. Process is waiting for something to happen.'

sleeping usually means waiting for I/O which means the process is waiting for input/output to complete, in your case reading and writing to USB
DoubtingT wrote:Eventually, after what seemed like an age, the process shut down, so the closebox obviously worked. The process itself causing the delay, perhaps?

What about the part emphasized part, does that mean you forcefully quit the process? Then you shot yourself in the foot and don't need to wonder why it shows as unformatted.

Re: Is format necessary for USB disk?

PostPosted: Oct 9th, '15, 15:42
by DoubtingT
Thanks for the replies.

Hi Filip,

I'm pretty sure I've made the same mistakes with diskdrake before, but after all these years (only using it when creating a new backup disk)
I'm still not comfortable with it.

I've now formatted without using the check disk for errors option. The process took a few seconds.
Thanks for reminding me of the right way to do it.

Hi Doktor5000
I know I shot myself in the foot by specifying an error check, but what I was trying to ascertain was whether
some on-the-fly formatting takes place in the background negating the need to do an initial format on a new disk.

Just to cap my incompetence...
Although I've now formatted the disk, with ext4 and ntfs3g partitions, I find I have no access rights to the ext4. That partition has ended up property of root, whereas the ntfs3g has ended up as property of user. I have no idea how this happened. Could someone please walk me through a solution?

Thanks.

Re: Is format necessary for USB disk?

PostPosted: Oct 9th, '15, 16:11
by doktor5000
DoubtingT wrote:I know I shot myself in the foot by specifying an error check, but what I was trying to ascertain was whether
some on-the-fly formatting takes place in the background negating the need to do an initial format on a new disk.


Usually new external drives will already be preformatted with NTFS filesystem. So if the new drive is recognised, and you want to use NTFS, then you don't need to format it.
New internal drives are usually not partitioned and not formatted.

If you wish to use a different partitioning scheme, you have to re-partition the disk. For a different filesystem then the default you will always have to format the partitions for which you want a different filesystem.
DoubtingT wrote:Although I've now formatted the disk, with ext4 and ntfs3g partitions, I find I have no access rights to the ext4. That partition has ended up property of root, whereas the ntfs3g has ended up as property of user. I have no idea how this happened. Could someone please walk me through a solution?

That is pretty simple. NTFS in native mode does not support unix ownership/permissions, so anybody with access to it can read and write to it.
ext2/3/4 filesystems, as most linux filesystems supports unix ownership/permissions, so you need to ensure that you either access it as root,
or to configure it so that only a certain user or a group of users has access to it. After all, you probably don't want any other user being able to read/write or delete the backups you put on the ext4 filesystem you created.

So for the ext4 partition, you can configure it so that your user has full access to it. That can be done via MCC, also in diskdrake: http://doc.mageia.org/mcc/5/en/content/drakdisk.html
Click on the ext4 partition and select the options button. I've currently no direct access to a Mageia system, so maybe you can try to figure out what option to set there.
You probably need to configure an option to be able to mount/unmount it as user, and the UID and/or GID (user ID and group ID) need to be set to your user.

You can display both by running
Code: Select all
id
as your (or any other) user

Do you know the basics about unix ownership and permissions? In case not, read up on it.
E.g. http://www.grymoire.com/Unix/Permissions.html or http://blog.superuser.com/2011/04/22/li ... mystified/

Does that make sense to you, or still some questions open? Don't hesitate to ask ...

Re: Is format necessary for USB disk?

PostPosted: Oct 9th, '15, 16:34
by DoubtingT
Hi Doktor5000

Thanks for the comprehensive reply.

In MCC I set the option to allow ordinary users to mount the disk. Came out of MCC. It didn't work. I unmounted the disk, removed it from the system and plugged it back in again. I went back into MCC. Now instead of sdb1, the disk is termed sdc1 with the NTFS partition termed sdc5. Additionally, the option for an ordinary user is unchecked again.

Am I okay to recheck the ordinary user option again despite the device name having changed?

I admit I'm getting paranoid about it.

Thanks.

Re: Is format necessary for USB disk?

PostPosted: Oct 9th, '15, 17:04
by doktor5000
At first, you do not mention for which partition you changed which option. You mentioned previously you created an ext4 and an ntfs3g partition on that disk.
Please show the output of the following commands as root first
Code: Select all
cat /etc/fstab
lsblk -o NAME,SIZE,FSTYPE,LABEL,UUID,MOUNTPOINT
mount

Re: Is format necessary for USB disk?

PostPosted: Oct 9th, '15, 18:10
by DoubtingT
I attempted to change ownership via the option dialogue on the ext4 partition. This was located on what was originally termed sdb1. The NTFS partition I created as an afterthought after formatting the entire drive in ext4.I didn't notice what terminology was handed to it.

The alteration to sdc1 (ext4) and sdc5 (NTFS) appeared to take place after I altered the ownership option; however, the actual change in ownership didn't take place.

Here is the output you asked for:
Code: Select all
[root@localhost ]#cat /etc/fstab
# Entry for /dev/sda5 :
UUID=0fa0af9e-9c2f-461d-98b5-2161f003a425 / ext4 defaults 1 1
# Entry for /dev/sda7 :
UUID=f47548c6-5271-44aa-b3d7-3dabd8b2b10c /home ext4 defaults 1 2
none /proc proc defaults 0 0
# Entry for /dev/sda6 :
UUID=c2ef5623-b895-4781-be84-bc1fc343622b swap swap defaults 0 0


Code: Select all
[root@localhost ]#lsblk -o NAME,SIZE,FSTYPE,LABEL,UUID,MOUNTPOINT
NAME     SIZE FSTYPE LABEL           UUID                                 
MOUNTPOINT
sda    931.5G                                                             
├─sda1    18G ntfs   PQSERVICE       C6E80BF5E80BE293                     
├─sda2   100M ntfs   SYSTEM RESERVED 96380C8D380C6F15                     
├─sda3 467.6G ntfs   Acer            B86E0DF86E0DB064                     
├─sda4     1K                                                             
├─sda5    12G ext4                   0fa0af9e-9c2f-461d-98b5-2161f003a425 /
├─sda6   3.9G swap                   c2ef5623-b895-4781-be84-bc1fc343622b [SWAP]
└─sda7 429.9G ext4                   f47548c6-5271-44aa-b3d7-3dabd8b2b10c /home
sdc    931.5G                                                             
├─sdc1 638.5G ext4   Elements        f673c262-1fce-4631-98d6-51a0670fbbd5
├─sdc2     1K                                                             
└─sdc5   293G ntfs                   0FA9737C39328211                     
sr0     1024M 
Code: Select all

[root@localhost ]#mount
proc on /proc type proc (rw,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
devtmpfs on /dev type devtmpfs
(rw,nosuid,size=1345912k,nr_inodes=199292,mode=755)
devpts on /dev/pts type devpts
(rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
/dev/sda5 on / type ext4 (rw,relatime,data=ordered)
securityfs on /sys/kernel/security type securityfs
(rw,nosuid,nodev,noexec,relatime)
tmpfs on /sys/fs/cgroup type tmpfs (rw,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup
(rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/usr/lib/systemd/systemd-
cgroups-agent,name=systemd)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/cpuset type cgroup
(rw,nosuid,nodev,noexec,relatime,cpuset)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup
(rw,nosuid,nodev,noexec,relatime,cpu,cpuacct)
cgroup on /sys/fs/cgroup/devices type cgroup
(rw,nosuid,nodev,noexec,relatime,devices)                                   
cgroup on /sys/fs/cgroup/freezer type cgroup
(rw,nosuid,nodev,noexec,relatime,freezer)                                   
cgroup on /sys/fs/cgroup/net_cls type cgroup
(rw,nosuid,nodev,noexec,relatime,net_cls)                                   
cgroup on /sys/fs/cgroup/blkio type cgroup
(rw,nosuid,nodev,noexec,relatime,blkio)                                       
systemd-1 on /proc/sys/fs/binfmt_misc type autofs
(rw,relatime,fd=27,pgrp=1,timeout=300,minproto=5,maxproto=5,direct)     
debugfs on /sys/kernel/debug type debugfs (rw,relatime,mode=755)                 
                                         
tmpfs on /tmp type tmpfs (rw)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
/dev/sda7 on /home type ext4 (rw,relatime,data=ordered)
gvfsd-fuse on /run/user/500/gvfs type fuse.gvfsd-fuse
(rw,nosuid,nodev,relatime,user_id=500,group_id=500)

Re: Is format necessary for USB disk?

PostPosted: Oct 10th, '15, 00:05
by isadora
Please place command-output between [CODE]-tags next time, to improve readability, thanks ahead!!! ;)
Demo: ftp://ftp5.gwdg.de/pub/linux/mandriva/m ... e_tags.ogv

Re: Is format necessary for USB disk?

PostPosted: Oct 10th, '15, 01:15
by DoubtingT
Apologies.

My first time. :?

Re: Is format necessary for USB disk?

PostPosted: Oct 10th, '15, 07:48
by isadora
No problem. ;)

Re: Is format necessary for USB disk?

PostPosted: Oct 10th, '15, 14:37
by doktor5000
DoubtingT wrote:I attempted to change ownership via the option dialogue on the ext4 partition. This was located on what was originally termed sdb1. The NTFS partition I created as an afterthought after formatting the entire drive in ext4.I didn't notice what terminology was handed to it.

The alteration to sdc1 (ext4) and sdc5 (NTFS) appeared to take place after I altered the ownership option; however, the actual change in ownership didn't take place.

For the device names (sdb and sdc, sdb1 vs. sdc1) that is nothing to worry about. The device names are being dynamically assigned when new devices are plugged,
if you would have quickly plugged it in and out a few more times you might have gotten sde or sdf, that's just how it works.


For changing the options, I totally forgot to mention that you need to assign a mountpoint to the partition.
Otherwise no entry is written to /etc/fstab (the file that you posted, which holds the entries that should be mounted on every boot) and hence no options can be applied.

For what it's worth, one more bit of information is required: Do you only want to read and write to the ext4 partition with your normal user,
or are there other users that should be able to write to that backup partition?

Re: Is format necessary for USB disk?

PostPosted: Oct 10th, '15, 15:16
by DoubtingT
Hi Doktor5000

Okay,

Thanks for listing the things I should watch out for. So, to recap:

Because they're assigned dynamically, I don't need to worry about the drive letters and numbers assigned to the partitions.

I do need to assign a mountpoint to the ext4 partition.

As I only want to read and write to the ext4 partition as a normal user, I don't need to extend any further privileges.

I think I'm set up with all I need for now as regards backing up.

My Mageia 4 installation was from a live CD. Can I use the upgrade arrow to install Mageia 5 automatically, or do I need to do a clean install?

Many thanks for your help.

Best.

Re: Is format necessary for USB disk?

PostPosted: Oct 10th, '15, 17:44
by doktor5000
DoubtingT wrote:Because they're assigned dynamically, I don't need to worry about the drive letters and numbers assigned to the partitions.

Yes and no :) Because they are not being referred to as sdc1 or sdb6 but they are referred to either via their UUIDs (unique IDs that are assigned when creating filesystems, can be seen in the lsblk output you provided) or via a label (which can be manually assigned to each partition, but is less commonly used).

DoubtingT wrote:I do need to assign a mountpoint to the ext4 partition.

As I only want to read and write to the ext4 partition as a normal user, I don't need to extend any further privileges.

Yes, and yes. In diskdrake for the ext4 partition choose or enter a mountpoint (e.g. /backup comes to mind) and in expert mode in the options enable the checkbox "user"
which automatically enables a few other related checkboxes. Then afterwards click OK and Done, diskdrake will ask you if it should write the changes to /etc/fstab
and /backup will be automatically mounted on every boot. If you don't want that, you can enable the noauto option in diskdrake.

It should look like this:
Bildschirmfoto2_201.png
Bildschirmfoto2_201.png (77.6 KiB) Viewed 2366 times

Bildschirmfoto2_202.png
Bildschirmfoto2_202.png (81.04 KiB) Viewed 2366 times


The only things that needs to be done afterwards is to adjust the permissions on the mounpoint /backup, as by default it belongs to root:root

Let me show you, starting point is mounting the partition as normal user, and the mountpoint belongs to root:root, as normal user I'm not allowed to write there:
[doktor5000@Mageia5]─[17:34:05]─[~] mount /backup
[doktor5000@Mageia5]─[17:34:36]─[~] df /backup
Filesystem Size Used Avail Use% Mounted on
/dev/sdb2 1.4T 70M 1.3T 1% /backup
[doktor5000@Mageia5]─[17:34:40]─[~]
[doktor5000@Mageia5]─[17:34:40]─[~] ls -ald /backup
drwxr-xr-x 3 root root 4096 Oct 10 17:32 /backup/
[doktor5000@Mageia5]─[17:35:33]─[~] echo -n > /backup/testfile
bash: /backup/testfile: Permission denied
[✗]─[doktor5000@Mageia5]─[17:35:37]─[~]


After adjusting owner and group to my regular user, he can write there jst fine:
[root@Mageia5]─[17:39:41]─[~] chown doktor5000:doktor5000 /backup
[root@Mageia5]─[17:39:51]─[~] ls -ald /backup
drwxr-xr-x 3 doktor5000 doktor5000 4096 Okt 10 17:32 /backup/
[root@Mageia5]─[17:40:27]─[~] su - doktor5000
[doktor5000@Mageia5]─[17:41:03]─[~] echo -n > /backup/testfile
[doktor5000@Mageia5]─[17:41:07]─[~]



DoubtingT wrote:My Mageia 4 installation was from a live CD. Can I use the upgrade arrow to install Mageia 5 automatically, or do I need to do a clean install?

No you don't need a clean install. Check the various methods and hints in our wiki: https://wiki.mageia.org/en/Mageia_5_Rel ... m_Mageia_4

[SOLVED] Re: Is format necessary for USB disk?

PostPosted: Oct 10th, '15, 23:59
by DoubtingT
Doktor5000,

I'm taken aback by the scope of your knowledge and the willingness you've shown to help out a fellow user. I've taken all your points on board, and I'm marking this thread as solved. Hopefully other less-informed users will look in on it and gather enough information to upgrade with confidence.

Thanks.

Best regards.