LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-09-2017, 08:40 PM   #1
cpu0
LQ Newbie
 
Registered: Dec 2016
Posts: 7

Rep: Reputation: Disabled
Smile 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.
 
Old 01-10-2017, 12:43 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 16,510

Rep: Reputation: 5552Reputation: 5552Reputation: 5552Reputation: 5552Reputation: 5552Reputation: 5552Reputation: 5552Reputation: 5552Reputation: 5552Reputation: 5552Reputation: 5552
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...
 
Old 01-10-2017, 12:20 PM   #3
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1062Reputation: 1062Reputation: 1062Reputation: 1062Reputation: 1062Reputation: 1062Reputation: 1062Reputation: 1062
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.
 
Old 01-10-2017, 12:27 PM   #4
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,585

Rep: Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351
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.
 
Old 01-10-2017, 02:02 PM   #5
beachboy2
Senior Member
 
Registered: Jan 2007
Location: Wild West Wales, UK
Distribution: Linux Mint 20.1 MATE, MX-19.3, antiX, EndeavourOS
Posts: 3,325
Blog Entries: 17

Rep: Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262
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.

Last edited by beachboy2; 01-11-2017 at 09:47 AM.
 
Old 01-10-2017, 02:05 PM   #6
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,585

Rep: Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351
Quote:
Originally Posted by beachboy2 View Post
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?
 
Old 01-10-2017, 02:07 PM   #7
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,319
Blog Entries: 13

Rep: Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372Reputation: 4372
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.
 
Old 01-10-2017, 02:17 PM   #8
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,585

Rep: Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351
Quote:
Originally Posted by rtmistler View Post
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.

Last edited by 273; 01-10-2017 at 02:19 PM.
 
Old 01-10-2017, 03:58 PM   #9
jailbait
LQ Guru
 
Registered: Feb 2003
Location: Mineral, Virginia
Distribution: Debian 8
Posts: 7,893

Rep: Reputation: 339Reputation: 339Reputation: 339Reputation: 339
Quote:
Originally Posted by cpu0 View Post
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 View Post
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
 
Old 01-10-2017, 04:49 PM   #10
beachboy2
Senior Member
 
Registered: Jan 2007
Location: Wild West Wales, UK
Distribution: Linux Mint 20.1 MATE, MX-19.3, antiX, EndeavourOS
Posts: 3,325
Blog Entries: 17

Rep: Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262Reputation: 1262
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.
 
Old 01-11-2017, 09:23 AM   #11
cpu0
LQ Newbie
 
Registered: Dec 2016
Posts: 7

Original Poster
Rep: Reputation: Disabled
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.
 
Old 01-11-2017, 12:01 PM   #12
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,585

Rep: Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351Reputation: 2351
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.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] sbopkg does not sync with proper branch BCarey Slackware 4 08-17-2016 11:55 AM
[SOLVED] proper syntax for a qemu command jr_bob_dobbs Slackware 5 02-26-2016 09:22 PM
Proper way to Sync Debian Mirror but preserve Sarge bizmarke Linux - Server 2 08-23-2010 05:38 PM
proper syntax for 'more' command bourne Linux - General 6 09-14-2007 09:26 AM
Shell Script help or proper command jmikeneedham Linux - General 2 04-30-2006 01:25 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:14 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration