LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Does mkswap -c secure? (https://www.linuxquestions.org/questions/slackware-14/does-mkswap-c-secure-924048/)

FeyFre 01-16-2012 10:31 AM

Does mkswap -c secure?
 
Hi

Recently I got into possession the one moderately old hard disk. So decided to use it partially as swap device. Created 4GB size partition at the beginning of disk and run mkswawp -c /dev/sdb1.

Question:
mkswap did its work and notified me about a number of bad blocks. Is is safe to use such partition as swap? I.e. can I hope those bad blocks became marked as such and will never be used by kernel?

Regards, Yaroslav

ponce 01-16-2012 10:42 AM

no, it's not safe: for what I know (the man page), mkswap doesn't mark bad blocks, it just reports them.

bad blocks under a certain number should be handled at SMART level and the operating system should not even see them: if you are seeing them it means that the drive is no more reliable.

read the old mkswap man page:
Quote:

Nobody wants to use a swap space with hundreds of bad blocks.
(I would not even use a swap space with 1 bad block.)

FeyFre 01-16-2012 11:33 AM

I have read somewhere too about mkswap behaviour with bad-blocks(about not marking, but counting only), but cannot remember where(and definitely not in man mkswap), so decided to try...
Quote:

bad blocks under a certain number should be handled at SMART
SMART said device has 96(or something like) relocated blocks. I don't know how much it for 100GB HDD.
In any case I have created ext2 partition(via mkfs.ext2 -c /dev/sdb2, mkfs.ext2 -cc takes more then 8 hours to finish, and I never let it done) on the rest of disk, and it made copy of inode tables on bad block(fsck reports the same write problem on the same block each time I run it). Does it means mkfs.ext2 doesn't marks bad blocks either?

PS: now I'm sure, why my system freezed once :) Neither remote nor console access was available, but animation in flashplayer continued to play independently(onboard shader?).

titopoquito 01-16-2012 12:06 PM

Quote:

Originally Posted by FeyFre (Post 4575994)
SMART said device has 96(or something like) relocated blocks. I don't know how much it for 100GB HDD.

Check to make sure the "raw value" (last column) of the SMART output in that line. I am no expert on smartctl and cannot read VALUE, WORST and THRESH values to make any meaning. From my experience, if you have one bad block you will get more and more bad blocks very fast. Show me one bad block and I am running to get a new harddisk. So to answer your question - yes, I think that 96 bad blocks (if that's the "RAW_VALUE" output) is way too much.

FeyFre 01-16-2012 02:18 PM

Code:

SMART Attributes Data Structure revision number: 16
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG    VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  1 Raw_Read_Error_Rate    0x000f  100  098  051    Pre-fail  Always      -      1
  3 Spin_Up_Time            0x0007  100  100  025    Pre-fail  Always      -      3456
  4 Start_Stop_Count        0x0032  094  094  000    Old_age  Always      -      6521
  5 Reallocated_Sector_Ct  0x0033  096  096  011    Pre-fail  Always      -      9
  7 Seek_Error_Rate        0x000f  100  100  051    Pre-fail  Always      -      0
  8 Seek_Time_Performance  0x0025  100  100  015    Pre-fail  Offline      -      9497
  9 Power_On_Half_Minutes  0x0032  099  099  000    Old_age  Always      -      7393h+28m
 10 Spin_Retry_Count        0x0033  100  100  051    Pre-fail  Always      -      1
 11 Calibration_Retry_Count 0x0012  100  100  000    Old_age  Always      -      0
 12 Power_Cycle_Count      0x0032  097  097  000    Old_age  Always      -      3596
194 Temperature_Celsius    0x0022  145  094  000    Old_age  Always      -      31
195 Hardware_ECC_Recovered  0x001a  100  100  000    Old_age  Always      -      1531
196 Reallocated_Event_Count 0x0032  086  086  000    Old_age  Always      -      32
197 Current_Pending_Sector  0x0012  100  100  000    Old_age  Always      -      0
198 Total_Offl_Uncorrectabl 0x0030  100  100  000    Old_age  Offline      -      0
199 UDMA_CRC_Error_Count    0x003e  200  200  000    Old_age  Always      -      0
200 Multi_Zone_Error_Rate  0x000a  100  100  051    Old_age  Always      -      0
201 Soft_Read_Error_Rate    0x000a  100  100  051    Old_age  Always      -      0

And I beginning to do not trust SMART. I know this HDD is quite old, but my primary HDD is no more than half year aged and it(SMART) shows very bad statistics(worst than for this HDD), but I have not any problems with it.

55020 01-16-2012 02:19 PM

AFAIK bad blocks only get revectored when the block is *written*. Neither mkswap -c or mke2fs -c perform writes, so any bad blocks will stay bad. (But mke2fs -c -c does do writes, see man mke2fs).

Look at 'smartctl -a /dev/sdb' to see how long ago all those errors happened. If they all happened at the same time a long time ago, the errors may have been caused by an external event (low external temperature, or being dropped, or power brown-out) and the disk *may* be ok.

To clear the bad blocks, I would do 'dd if=/dev/zero of=/dev/sdb bs=16384', and then do 'dd if=/dev/sdb of=/dev/null bs=16384', and then look at dmesg. If there were no kernel errors logged in the second 'dd', the disk *may* be ok.

But I certainly wouldn't put the only copies of photos of my children on that disk...

titopoquito 01-16-2012 04:52 PM

Quote:

Originally Posted by FeyFre (Post 4576137)
Code:

ID# ATTRIBUTE_NAME          FLAG    VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  5 Reallocated_Sector_Ct  0x0033  096  096  011    Pre-fail  Always      -      9

And I beginning to do not trust SMART. I know this HDD is quite old, but my primary HDD is no more than half year aged and it(SMART) shows very bad statistics(worst than for this HDD), but I have not any problems with it.

As I understand it you have 9 reallocated sectors. Do what 55020 suggested and make a backup of your important files. Did you already perform a long disk self test with smartctl? Might be a bit paranoid, but in my case when the first reallocated sectors occured on any disk others came along very quickly. I wouldn't be too worried about these other "pre-fail"s though.

FeyFre 01-16-2012 06:14 PM

Quote:

a backup of your important files.
Using that disk as a storage of downloadable, rarely used data(can be redownloaded in a few hours).

onebuck 01-17-2012 10:29 AM

Member response
 
Hi,

I would get the manufactures disk diagnostics and perform to hopefully get a reliable result. You should not use the drive until certain that the bad blocks are indeed 'bad'. Especially within areas that are to be used for swap.

Most certainly do not use with a swap partition on it. Not reliable and you will just open Pandora's box to use a swap partition with bad blocks. You could use a 'swapfile' by 'dd if=/dev/zero of=swapfile bs=1024 count=65536' then use mkswap on that 'swapfile' to confirm and create the swapfile with no errors. Do a 'man mkswap' to fully understand.
HTH!
:hattip:

FeyFre 01-17-2012 10:46 AM

Quote:

You could use a 'swapfile' by 'dd if=/dev/zero of=swapfile bs=1024 count=65536'
Yse, I do know about 'swapfile'. Really, I don't need swap at all(it is not so easy to fill up 2GB RAM). Primary goal of using swap is to have ability to go into S4. Apparently swapfile is not usable solution here yet(at least I do not know any case).


All times are GMT -5. The time now is 07:13 PM.