LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   the sync command and proper use (https://www.linuxquestions.org/questions/linux-newbie-8/the-sync-command-and-proper-use-4175597123/)

cpu0 01-09-2017 08:40 PM

the sync command and proper use
 
Hi, I'm a new Linux shell user (Bash).

I used several distros and tried to format my hard drive using the dd command. After I did this (sometimes it took several hours), I rebooted and when I checked the formatted hard drive the partitions on it were still there. On some distros this was the case and on others the hard drive partitions were gone. I later found out about the sync command and supposedly that it flushes commands out of a que. I have been using it after almost all commands now, but I think I am learning a bad habit. The dd command for example cant flush format a hard drive after a sync command.

My question is not about formatting my hard drive, but it's about being a dunce at the shell level. How useful is the sync command and what would be a proper example of its use.

Since formatting is not a question, I would still be interested if anyone knows why dd sometimes works and other times it does not. I would like to know if it's safe to sell some of my old hard drives? I still prefer platter drives, though I have a few ssd's.

Sorry, not new to linux, but total shell noob. I guess that means Linux noob anyway lol.

pan64 01-10-2017 12:43 AM

first of all see: man sync. Next, I would say sync is rarely used, and if you properly shut down/reboot your pc you will not need it at all (on this level). (no, sync will not flushes commands)
dd cannot format disks, but it can write data to/from hard drives. I think you wanted to clean up your disk (but I'm not really sure about that).
Without telling us how did you execute dd (what was the real command, what's happened, what did you want to achieve) we cannot say more, but I guess you either mistyped something or missed something...

tronayne 01-10-2017 12:20 PM

What sync does is flush system buffers to either a disk or a flash drive or other form of memory (like a camera memory card). It is useful when you're writing to a flash drive and you're waiting for the thing to be completely written so you can remove it (they're slow and it can take some minutes for the system to roll around and sync the write -- there is no problem using it you're writing a huge amount of stuff to a device).

dd, as mentioned above, does not format a disk, you must have done that before trying to write to it. You will use fdisk or sfdisk or cfdisk to create partitions followed by [I]mkfs/I] to create a file system on that partition (plus adding the partition to /etc/fstab to mount it so you can use it. You probably want to format the partition with an ext4 type. There is also the parted utility and there may be a GUI utility for managing partitions and file systems.

Check your documentation about doing so.

273 01-10-2017 12:27 PM

If you want to sell a drive then formating alone will not clar any data from it.
If you are worried there may be personal data on the drive then using something dban may be worth it but, really, a single-pass of zeroes is enough to wipe data on drives made in the last decade unless you're actually doing something somebody may spend tens pof thousands of dollars (to pick a currency) to find out about. In which case, you're likely too rich to care about using thermite to destroy a hard drive or three.

beachboy2 01-10-2017 02:02 PM

cpu0,

First of all DBAN will NOT securely wipe a drive because it does NOT erase hidden areas like HPA and DCO.

Blancco does and so does Secure Erase.

Secure Erase is the name given to a set of commands available from the firmware on PATA and SATA based hard drives manufactured since 2001.

Use Parted Magic (contains Disk Eraser):

Download the FREE pmagic_2013_08_01.iso from Major Geeks, not from the Author’s site because it will cost you money:

http://www.majorgeeks.com/files/deta...ted_magic.html

Parted Magic with GParted is one of the best Linux bootable CD environments around today for partitioning and erasing hard drives and is also recommended by companies like Corsair for erasing SSD’s.

Simply download the Parted Magic ISO and write it to CD/DVD or USB and boot from it.

Parted Magic review:
http://www.makeuseof.com/tag/parted-...olbox-live-cd/

The Disk Eraser icon should be on the desktop, but if not, it’s found in the Start menu -> System Tools.

In the main window there will be options to zero the MBR, drive or partition using different methods.

The Internal Secure Erase method is the most important because it issues the ATA erase command found in the firmware of nearly all drives since 2001.

This is more secure than overwriting with 0′s, 1′s or random data using 3rd party tools and is the recommended way to wipe a hard drive or SSD if your drive supports it.

273 01-10-2017 02:05 PM

Quote:

Originally Posted by beachboy2 (Post 5653020)
cpu0,

First of all DBAN will NOT securely wipe a drive because it does NOT erase hidden areas like HPA and DCO.

So how would, for example, my credit card information, once entered into the browser, be stored in such areas? If I have a client database with social security numbers, how would they be stored in such areas?

rtmistler 01-10-2017 02:07 PM

I simply would never sell an old hard drive which had my personal data. First, the drive is old, and usually for my case it might be very old. Why would I find any worth in sharing that with the world? It's like far smaller than current technology, and has had a lot of data written, erased, etc. If I decided that I wished to protect any potential data of mine, the way I'd protect it would be to destroy the drive and discard it, not try to ensure the data is adequately shredded and then sell it with any potential question mark in my mind.

273 01-10-2017 02:17 PM

Quote:

Originally Posted by rtmistler (Post 5653027)
I simply would never sell an old hard drive which had my personal data. First, the drive is old, and usually for my case it might be very old. Why would I find any worth in sharing that with the world? It's like far smaller than current technology, and has had a lot of data written, erased, etc. If I decided that I wished to protect any potential data of mine, the way I'd protect it would be to destroy the drive and discard it, not try to ensure the data is adequately shredded and then sell it with any potential question mark in my mind.

Perhaps you only used the drive for a little while? Perhaps it's still showing OK in SMART controls? Perhaps you think it's better to recycle it by passing it on rather than spending power in deconstructing it as part of the recycling process? Perhaps you realise that a single dd sweep leaves no doubt unless you've something to hide worth hundreds of thousands of dollars*?
This whole hard-drive paranoia since the Gutmann paper is completely out of proportion to any threat ever posed.
Or, perhaps, I'm wrong and somebody has a link to a peer-reviewed paper stating otherwise?

I'm all for privacy and I don't agree that "if I've nothing to hide I have nothing to fear" so I think that this hard-drive paranoia is actually more dangerous. For example, if you overwrite a hard drive with [pseudo]random data in the UK and you happen to be arrested for an offence which means your computer will be searched it may mean you spend 5 years or more in prison. IF you're arrested in any country on any charges and you've a bunch of melted hard drives to your name, I see the word "terrorist" in your future.

Perhaps DBAN isn't the tool -- I'd use dd or dcfldd myself but, really, please either somebody come up with actual proof that some criminal can read data from an erased hard drive or stop being so silly.

*NB I note that there are still no companies even trying to suggest they can recover even partially overwritten data from hard drives, despite how much data recovery costs for even a drive which has been formatted or the controller has gone.

jailbait 01-10-2017 03:58 PM

Quote:

Originally Posted by cpu0 (Post 5652705)
My question is not about formatting my hard drive, but it's about being a dunce at the shell level. How useful is the sync command and what would be a proper example of its use.

Whenever you umount a drive umount includes a sync. When you do such things as shutdown, halt, or reboot those commands include umount commands for all of your mounted partitions. So it is rare for you to need to issue a stand alone sync command.

Quote:

Originally Posted by cpu0 (Post 5652705)
Hi, I'm a new Linux shell user (Bash).

I used several distros and tried to format my hard drive using the dd command. After I did this (sometimes it took several hours), I rebooted and when I checked the formatted hard drive the partitions on it were still there. On some distros this was the case and on others the hard drive partitions were gone. I later found out about the sync command and supposedly that it flushes commands out of a que. I have been using it after almost all commands now, but I think I am learning a bad habit. The dd command for example cant flush format a hard drive after a sync command.

Since formatting is not a question, I would still be interested if anyone knows why dd sometimes works and other times it does not.


dd is subject to all sorts of fluky errors caused by drive geometry, partition size, etc. I suggest that you format your partitions with gparted.

-----------------
Steve Stites

beachboy2 01-10-2017 04:49 PM

273,

Quote:

So how would, for example, my credit card information, once entered into the browser, be stored in such areas? If I have a client database with social security numbers, how would they be stored in such areas?
Those items would not normally be stored in such areas.

cpu0 01-11-2017 09:23 AM

Thanks everyone. Here is what I figured out from what you guys said:

sync does not do anything (for me I mean, I was senselessly using it, but I will remember the flash drive bit for future reference).

Formatting my drive: sorry my mistake, I was using dd to "wipe" the drive.

Thanks for mentioning the overwrite with 0's is enough. I googled a little while ago and found someone mentioned the same thing, so it makes more sense now. However, I agree about physically destroying a hard drive. So I guess if it fits the scenario, than it depends on how critical it is.

Parted Magic: purchased it, love it, can't figure out how all those 0's and 1's disappear in under 2 seconds on secure erase (joke), it will take some time to get used to it. I did not believe the drive was erased that fast.

As for wiping a drive now. I will either use Parted magic as said with just zeros, or if I think something is too sensitivem but not too critical, then I found this to be useful - #time shred -n1 -f -v -z /dev/sd*

That is basically a time command to tell you how long it took when finished and the rest is the shred command with -n1 that says overwrite random, followed by overwrite with 0's. The default is 3x random + 1x 0's, which takes like 7 hours.

273 01-11-2017 12:01 PM

Rather than zeros /dev/urandom could be a good choice as a source for dd just to make a token effort almost guaranteed to stop even STMs from picking up the data.


All times are GMT -5. The time now is 07:03 AM.