Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Tuesday, February 11, 2014

Raspberry Pi Journal #49



SD Card Formatting



There's quite a bit of discussion on how to format the SD card. The easy way to do it is to just gparted program. It's point and click easy. However, what if you want to do it automatically? Use *sfdisk* program.

Once you prepped the SD card using gparted, use the sfdisk program to dump the info out to a file. This is what I did in order to get 4 GB file data.


  • sudo sfdisk -d /dev/sda > SD4GFAT32.sdmap
  • cat SD4GFAT32.sdmap 
  • # partition table of /dev/sda
  • unit: sectors

  • /dev/sda1 : start=    16384, size=  7684096, Id= b
  • /dev/sda2 : start=        0, size=        0, Id= 0
  • /dev/sda3 : start=        0, size=        0, Id= 0
  • /dev/sda4 : start=        0, size=        0, Id= 0




So that's the file, and its content. Now, if you redid the whole partition using gparted to something like this:


  • sudo sfdisk -d /dev/sda 
  • Warning: extended partition does not start at a cylinder boundary.
  • DOS and Linux will interpret the contents differently.
  • # partition table of /dev/sda
  • unit: sectors

  • /dev/sda1 : start=     2048, size=  4319232, Id= b
  • /dev/sda2 : start=  4352000, size=  3356672, Id= 5
  • /dev/sda3 : start=        0, size=        0, Id= 0
  • /dev/sda4 : start=        0, size=        0, Id= 0



You can use sfdisk to restore it to its former partition, thus reformatting the SD card.


  • sudo sfdisk /dev/sda < SD4GFAT32.sdmap 
  • Checking that no-one is using this disk right now ...
  • OK

  • Disk /dev/sda: 1020 cylinders, 122 heads, 62 sectors/track
  • Warning: extended partition does not start at a cylinder boundary.
  • DOS and Linux will interpret the contents differently.
  • Old situation:
  • Units = cylinders of 3872768 bytes, blocks of 1024 bytes, counting from 0

  •    Device Boot Start     End   #cyls    #blocks   Id  System
  • /dev/sda1          0+    571-    572-   2159616    b  W95 FAT32
  • /dev/sda2        575+   1019-    444-   1678336    5  Extended
  • /dev/sda3          0       -       0          0    0  Empty
  • /dev/sda4          0       -       0          0    0  Empty
  • New situation:
  • Warning: The partition table looks like it was made
  •   for C/H/S=*/6/18 (instead of 1020/122/62).
  • For this listing I'll assume that geometry.
  • Units = sectors of 512 bytes, counting from 0

  •    Device Boot    Start       End   #sectors  Id  System
  • /dev/sda1         16384   7700479    7684096   b  W95 FAT32
  • start: (c,h,s) expected (151,4,5) found (2,20,17)
  • end: (c,h,s) expected (1023,5,18) found (1018,5,18)
  • /dev/sda2             0         -          0   0  Empty
  • /dev/sda3             0         -          0   0  Empty
  • /dev/sda4             0         -          0   0  Empty
  • Warning: partition 1 does not start at a cylinder boundary
  • Warning: partition 1 does not end at a cylinder boundary
  • Warning: no primary partition is marked bootable (active)
  • This does not matter for LILO, but the DOS MBR will not boot this disk.
  • Successfully wrote the new partition table

  • Re-reading the partition table ...

  • If you created or changed a DOS partition, /dev/foo7, say, then use dd(1)
  • to zero the first 512 bytes:  dd if=/dev/zero of=/dev/foo7 bs=512 count=1
  • (See fdisk(8).)




Just to make sure, here's the command again.


  • sudo sfdisk -d /dev/sda 
  • # partition table of /dev/sda
  • unit: sectors

  • /dev/sda1 : start=    16384, size=  7684096, Id= b
  • /dev/sda2 : start=        0, size=        0, Id= 0
  • /dev/sda3 : start=        0, size=        0, Id= 0
  • /dev/sda4 : start=        0, size=        0, Id= 0


One more thing. If you want to reformat the partition to FAT32 filesystem, you can do this:


  1. sudo mkfs -t vfat /dev/sda1


Yes, you need to format each partition separately, and that means you can have different file system per partition. Also, vfat stands for FAT32, although you can specify it explicitly, or use something else entirely.


Wednesday, August 14, 2013

Raspberry Pi Journal #5



SD Back Up Frustrations


So, I was going to back up my SD card. I think that there is a good chance that my SD card will go bust someday. I'd like to be protected. Considering that I install a lot of program, and it's not over yet, there is an excellent chance that the SD card will go out eventually. Especially since omxplayer is still messing up my system. The last time I used it, the screen actually got shifted in the middle. That is, all four corners of the desktop are centered on the screen. Sigh.

So, having the need to back up my SD card, how do I do it? A lot of instructions on the Internet says to use Win32 Disk Imager. I suppose it works fine, but come on, Debian is a very powerful OS. Are you saying I have to use Windows just to back up a Linux OS? That's silly.

So, I dig deeper. It turns out that I have to dig quite deep to uncover DD. DiskDump (or Disk Destroyer) seems to work fine. This is how you use it:

dd if=/dev/sdb of=/path/to/backupfile.img
if=input file or sd card
of=output file

And this is where I stop. The method obviously works if you're copying an SD card to another place, such as a flash drive. But, how will this back up my current system? I have to take it out of the machine and back it up manually? That's not how back up supposed to work, does it?

I understand that the output is not compressed, but I don't see it as a drawback. You can simply output to sdout and pipe it to gzip. There you go, compressed on the fly!

I also understand that if I specify the wrong SD card, I can mess things up. I read very carefully the text I have, but there is no specific mention how the SD card will be destroyed. I'm assuming that the destruction will happen on the output side, not the input side. But if so, isn't that natural?

All I can tell you is that the process will not backup the current running OS. Also, there is no instruction on how to restore the data. The only hint is that if "of" is given drive, it will try to "rewrite the whole disk". I'm wondering if that means the whole partition is intact. If indeed we're copying two SD cards, mirroring one another, I think that's a desirable outcome since that way, we get to skip a step. If one card is busted, well, no need to reflash the SD. Just use the back up SD right away!

Researching this method of back up is very frustrating and time consuming. Mirroring SD card is not what I'm looking for! I want to back up the OS, and I want to know how to do it, live.

I'm thinking to partition /boot and /home separately. I think I can just tar /home like this:

tar -cvzf tarball.tar /home/ 

and that's that. Extract the files by

tar -xvzf tarball.tar /home/

That should do nicely. I also wonder if the command

tar -xvf tarball.tar

all by itself is enough. I checked it. Sure enough, it works! Apparently, there is a check in there if the archive is compressed, it will automatically decompress. I checked out the output and there seems to be 4 bytes difference. I wonder why that is. There's no other differences that I can see.


There are two commands that you can use: "tar --help" and "tar --usage". Both screens are simultaneously overkill and not enough sample usage for everyday use. Hmmmph.

In any case, I still don't know how to back up my system, without shutting it down and take it out to another computer. Very frustrating!

Do you people are actually satisfied with the back up instruction that requires you to shutdown your Raspberry Pi, remove the SD card to Windows machine, and run a disk imager? I know that Linux has a live-back up system. How about doing instruction for that? I have an SD card in Raspi, and another one via USB. I want to backup the system to that USB+SD card. It's okay if I have to get a bigger card, but please don't tell me I need to shut the system down! That's just so inconvenient, and isn't the idea of getting a computer is convenience?

There are many, many web pages that tells you to use Windows to back up your SD card. Hello? Do you not see why that is not desirable? Worse, the instructions just mirror one another. I get repetitive instructions that is useless, and really, just a bunch of noise. I ran out of time trying to dig out the proper instruction. And before you ask, yes, I searched for "live backup". The few forum pages that I've seen, skirted the issue and did not answer at all.

I'm pretty sure there is a proper instruction in there somewhere, because I'm having trouble believing that people are willing to put up with shutting down the device every time you want to make a back up. It's just that the bad instructions are everywhere, and not enough people putting out good instruction to counter it. I have yet to check this, but I'm getting very frustrated. I wonder if the "back up your Pi with Windows" instructions are even in TheMagPi magazine? Because, IMHO, that's the boneheaded way to do it. Learning computers are fragile, and what good would it do to send cheap computers if you need an expensive one just to back up your data?

Of course, next thing I know, lots of people will be criticizing me for unwilling to pull the SD card out of the Raspi to make a daily back up. Uh-huh. And they wonder why people don't back up their SD cards.


BTW, I finally did an "rsync -r --progress * /media/5185-5397" where the number is the SD card on my USB. Works fine ... for a directory.







Tuesday, August 6, 2013

Raspberry Pi Journal #3

Printer Trouble


I was printing my other blogspot for archival purposes, when I realized that I was double printing the month of June. I quickly cancel the print process, except it already got sent to the server, and I couldn't open up the web page quick enough for me to cancel the print. So, I did what I know would work: Turn off the printer.

Sure enough, when the printer administration web page came up, it said unable to send job to the printer. So far, so good. Obviously, I cancelled all print jobs so far.

The trouble was, I couldn't send any new print job to the printer! After trying various attempt over 10 minutes, I gave up and rebooted the computer and printer. This should have worked. Except, it didn't!

More going around to check the printer. It's not until I stumbled upon "Resume Printer" option in the Maintenance menu that I am able to print again. Apparently, there is a status recording somewhere that cause the printer to be invalid until "resumed", whatever that means.

I think this is bad behaviour.I should be able to reset the printer by turning it off. Smart devices are way too smart these days. It's no longer just a simple turn off, turn on for resetting their values. What if something got screwed up inside? You'll have to take it to the service department. What a hassle!

Libre Office trouble

I was doing multiple windows on Libre Calc, when I found out that the new window I spawned was affecting the old window as well. Of course, this happens after I'm done all editing with the new window. There goes my work out the window! To be honest, this is the first time I've seen it happen. I wonder what the purpose is to link multiple windows to a file?

In the end, I simply toss out all changes. Reload the old file, and save under different name. Close all windows, and load all files. Problem solved, but more time wasted. Growing pains, I suppose.