Welcome! Log In Create A New Profile

Advanced

Rsync writing to boot flash drive?

Posted by hanker 
Rsync writing to boot flash drive?
March 10, 2011 10:07AM
I've asked about this on forums.debian.net but have gotten no solution so far.

I installed Debian to my Dockstar using the Doozan script. It also has two 1 TB usb hard disks hooked to it.

The machine is used for only rtorrent and nfs. The flash drive contains only the system software and rtorrent. All of the data that rtorrent moves around is on the usb hard disks, including downloaded data, watch folder, and session folder. rtorrent is configured to not have a log file.

About once a day I run rsync with the source being one usb hard disk and the target being the other usb hard disk:

# rsync --progress --stats -a --delete /media/usb_1/ /media/usb_2

Since this machine boots from a usb flash drive, I'm interested in keeping the number of writes to the flash drive to a minimum.

The machine used to boot from an Adata flash drive, which has no LED. That drive wore out after about five months. Completely dead, as in gparted would fail with an I/O error on write when trying to write a new partition table to it. No big deal - I restored the software to a new flash drive using an image I had made in Clonezilla.

The new drive (a Sandisk Cruzer 4 GB) has an LED, and I assume this is showing me when the drive is being accessed, read and write. When the system is at idle, the LED sort of "breathes" off and on slowly. When rtorrent is downloading or uploading, it flashes a few times and goes back to breathing.

I'm assuming that once everything has been loaded and the system has been running a while, that when the LED flashes, that means that data is being written to the flash drive. (Is this a good assumption?) With just rtorrent running, there's not much flashing, maybe 10 - 20 times/minute. I'm not sure why it's writing to the boot flash drive, but it does. Maybe it's swap activity.

However when rsync is running, the boot flash drive LED just flashes on and off like crazy. The daily rsync run takes anywhere from three to 30 minutes, depending on how much new data was downloaded each day. But no matter how long it takes, the flash drive LED just flashes like crazy the whole time.

I've checked this with iostat and have verified that while rsync is running between the two usb hard disks, there is a significantly (one to two orders of magnitude) greater amount of writing to the boot flash drive than when only rtorrent is running. I have a feeling that this may be what wore out the original boot flash drive.

I'm unclear on why this is. I'm unclear on why rsync should cause any writes to the boot flash drive. I would think that once rsync starts, all of its code would be loaded into RAM and execute from there and that chunks of data from the usb hard disks would be loaded to RAM and then would be compared, processed, etc., there. Why does it need to read/write from/to the boot flash drive over and over when I'm not rsyncing any of the data to or from the boot flash drive?

Is there a way to get rsync not to do this and to do its thing in RAM only and not write to the boot flash drive?

Would it work to change the relevant line in /etc/fstab from

/dev/root / ext2 noatime 0 1

to

/dev/root / ext2 ro 0 1

?

Or would this break things horribly? I have rtorrent configured so that all of its data is on the usb hard disks - it shouldn't be writing anything to the boot flash drive.

Or can I set the boot disk to read-only after boot or something like that?

What makes this very confusing to me is that I frequently boot machines from a Clonezilla liveusb (which is Debian-based) to duplicate, restore, and make images of multi-GB hard disks and portable storage devices (flash drives, SD cards). Once I start the operation, the Clonezilla liveusb just sits there unblinkingly and evidently unwritten to while large amounts of data are shuffled between madly blinking non-boot usb hard disks, etc.

Any ideas on this are appreciated.



Edited 1 time(s). Last edit at 03/10/2011 03:07PM by hanker.
Re: Rsync writing to boot flash drive?
March 10, 2011 03:10PM
Unless your *nix is set up for a read-only root, I think it would break things to simply declare / a ro file system.

If it were me, I'd use 'lsof' to try to understand what 'rsync' is doing during these sessions. I suspect it may be maintaining either an open unattached temp file or pipe which it is writing to.

The other thing I would suggest is that you consider simply putting the root file system on your 1TB hard drive and pitching the thumb drive in your desk as a backup. Doing this has its pros and cons, but it sound like in your case it would resolve all your problems.
Re: Rsync writing to boot flash drive?
March 10, 2011 05:57PM
restamp Wrote:

> If it were me, I'd use 'lsof' to try to understand
> what 'rsync' is doing during these sessions. I
> suspect it may be maintaining either an open
> unattached temp file or pipe which it is writing
> to.

Good idea.

I started rsync and then did this:

lsof | grep rsync

and it turns out that rsync holds a number of files open other than the ones on the the disks that are being rsynced. Not sure why, but there it is. A few representative entries:

rsync     2152     root    1u     unix 0xc69af860        0t0    3008467 socket
rsync     2152     root    2u      CHR      136,6        0t0          9 /dev/pts/6
rsync     2152     root    3u     unix 0xc69afa00        0t0    3008476 socket
rsync     2153     root  cwd       DIR       8,33       4096          2 /media/usb_2
rsync     2153     root  rtd       DIR        8,1       4096          2 /
rsync     2153     root  txt       REG        8,1     362752     153929 /usr/bin/rsync
rsync     2153     root  mem       REG        8,1     122340       2288 /lib/ld-2.11.2.so
rsync     2153     root  mem       REG        8,1      25452       2279 /lib/libacl.so.1.1.0
rsync     2153     root  mem       REG        8,1      43604       4765 /lib/libpopt.so.0.0.0

etc., etc.

> The other thing I would suggest is that you
> consider simply putting the root file system on
> your 1TB hard drive and pitching the thumb drive
> in your desk as a backup. Doing this has its pros
> and cons, but it sound like in your case it would
> resolve all your problems.

Yep. So I happened to have a Toshiba "My Portable" 20 GB 1.8 inch external, bus powered usb hard disk lying around. I Clonezilla-restored the image of the Debian/rtorrent/nfs software load that I run to it and it booted the Dockstar no problem :)

It seems to be working just fine.

Thank you for your reply.
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: