Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/rvm/rubies/ruby-2.6.2/bin/ruby
- # b = (int)((L-S)*512/B)
- # where:
- # b = File System block number
- # B = File system block size in bytes
- # L = LBA of bad sector
- # S = Starting sector of partition as shown by fdisk -lu and (int) denotes the integer part.
- lba = ARGV[0].to_i
- dev = ARGV[1] || 'add_your_device_label_here'
- block_range = ARGV[2].to_i || 64
- iterations = ARGV[3].to_i || 100
- block_number = ((lba - 2048)*512)/4096
- bb_cmd = "sudo badblocks -b 4096 -p #{iterations} -s -vw /dev/#{dev} #{block_number+block_range} #{block_number-block_range}"
- puts "execute command: #{bb_cmd}? [y/N]"
- run_command = $stdin.gets.chomp
- if run_command == ("y" || "Y")
- `#{bb_cmd}`
- else
- puts "run: #{bb_cmd}"
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement