One place for hosting & domains

      Create

      How to Create an Email Newsletter (And Why You Should)


      It seems like everyone has a newsletter these days. In fact, you probably stumble across newsletter sign-up forms on most sites you visit. While the many invitations can seem overwhelming, there’s a reason so many sites want your email address.

      As it turns out, running a newsletter is a smart move for many reasons. It can help you increase brand awareness, improve user engagement, and even generate more sales. The best part is that creating and sending a newsletter doesn’t have to be difficult or time-consuming.

      In this article, we’ll take a closer look at the benefits of running a newsletter for your website, using our own The WordCandy Weekly as an example. We’ll also discuss what you can do with your newsletter, before showing you the basics of how to set one up for yourself. Let’s get to work!

      A Brief Introduction to Email Newsletters

      The sign-up form for The WordCandy Weekly.

      Chances are that you’re pretty familiar with newsletters. They’ve become as much a part of everyday internet life as blogs or cat memes. In fact, you probably receive at least a few of these messages in your inbox on a weekly or daily basis.

      When something becomes that mundane, you can easily to forget why it became so popular in the first place. You might even expect that newsletters aren’t as useful as they once were. However, the reality is that they’ve seen something of a resurgence in recent years.

      One of the main reasons for their continuing popularity is that newsletters offer a straightforward way to digest news and updates, without needing to seek out the information on social media. In addition, mobile web usage is becoming increasingly popular. Among other things, this means people are more likely to check their emails on the go, making newsletters more useful than ever.

      Of course, we should clarify that while the term ‘newsletter’ implies that these messages are used to communicate news, that’s not their only application. You can also use your newsletter to promote products and services, let people know about upcoming events, solicit feedback, and much more. You can even create automated emails that trigger at specific times or are sent when a user performs a particular action (more on this later).

      The point is that newsletters offer you a lot of freedom and can be applied to the specific needs of your business. Before we discuss how to start one up, let’s dig deeper into how they can benefit you.

      Why You Should Consider Starting Your Own Newsletter

      Naturally, getting a newsletter off the ground will require you to invest a certain degree of time and effort. As such, it will need to provide benefits to offset the costs. With that in mind, let’s take a look at some of the ways a newsletter can benefit you and your business.

      For example, a newsletter can:

      • Help you increase traffic and engagement. If you use your newsletter to highlight your products or content, you can raise awareness and interest in what you’re offering. This also helps your audience stay on top of everything you do.
      • Let you control your message. You can inform users directly about news and other valuable information right away. As such, your existing audience will hear everything straight from you, and you’ll have control over how it’s presented.
      • Enable you to connect directly with your users. Newsletters are a perfect tool for creating a personal connection with your users since you can address them directly. You can also segment your audience to create email campaigns that are specifically tailored to a smaller part of your overall customer base.
      • Generate more conversions. Since a newsletter enables you to raise awareness and publicize your offerings, it often leads to more conversions and even increased revenue.

      As we mentioned earlier, how you decide to use your newsletter will depend primarily on your goals and business model. For example, an e-commerce business might leverage emails to highlight products, publicize deals, and even provide offers that are unique to subscribers.

      However, you can also use your newsletter more holistically. It doesn’t even have to be directly (or even indirectly) related to your actual business. Instead, you can provide general information that’s of interest to your audience, offering a service rather than engaging in direct marketing.

      One example of this in action is is our own newsletter: The WordCandy Weekly. This is a regular news roundup of the latest stories from the WordPress community.

      An issue from The WordCandy Weekly.

      At WordCandy, we provide content solutions for WordPress businesses so this resource is obviously relevant to our company. At the same time, it’s not directly tied to the work we produce.

      Instead, our intention with this newsletter is to provide value to our existing clients and readers. By doing that, we’ve been able to help our subscribers stay up-to-date with news that matters to them. At the same time, we can raise awareness of our business, without needing to spend time and money on marketing or compromising the value of the product.

      In other words, this is a type of promotion that benefits all parties. By using a newsletter in this way, you can better establish yourself as a knowledgeable part of your niche or community. You can also grow your brand awareness, all while providing a genuinely useful service to your mailing list.

      This doesn’t mean there’s anything wrong with using your newsletter for direct promotion, of course. Which route you decide to use will depend largely on your business, target market, and goals. An excellent starting point is to study newsletters created by businesses and websites that are similar to yours, and see if there’s a particular niche or need that’s currently unfulfilled.

      How to Create a Newsletter

      Once you’ve settled on a concept for your newsletter and know what you want it to focus on, it’s time to start putting it together. If you’re worried that this means manually sending hundreds or thousands of emails from your personal inbox, you’ll be pleased to hear that the actual process is much more painless.

      In fact, there are plenty of solutions that can help you create and manage your newsletter. If you have a WordPress site, you can even do this straight from your admin dashboard by using a plugin like Jackmail.

      The Jackmail plugin.

      You can use this plugin to incorporate your newsletter directly into your site. Jackmail even makes it possible to generate automatic emails at predetermined times, such as whenever you publish a new post. It also includes an email builder, enabling you to create gorgeous templates for your messages with ease.

      Another popular solution, and the one we use for our own newsletter, is Mailchimp.

      The Mailchimp home page.

      Mailchimp is a perfect newsletter solution for almost any application; it’s easy to use while providing a lot of opportunities to customize your email campaigns. It offers many key features, along with various ways that you can integrate your Mailchimp account with other platforms. Like Jackmail, it also includes an intuitive email builder, along with a series of pre-made templates you can use.

      This particular solution also has a robust free plan, which enables you to gather up to 2,000 subscribers and send up to 12,000 emails every month. This should be more than enough to begin with, and when your list start to grow, you can always upgrade to a premium plan.

      Which solution you decide to use will once again depend on your preferences, as well as what specific features you need. However, it’s vital to remember that whether your newsletter becomes a success will depend primarily on the quality of its content.

      3 Tips for Making Your Newsletter a Success

      After choosing an email marketing solution and putting in place a general plan for your newsletter, you’ll just need to ensure that you take advantage of its full potential. To give you a running start, here are some tips that will help you optimize your newsletter.

      1. Create a Simple, Attention-Grabbing Template

      One of the most important (and fun) aspects of creating your newsletter is putting together your template. As you might expect, this template will be the basis for your newsletter design. This way you can keep each message’s look the same while adding new content each time.

      For example, the template we use for our weekly newsletters looks like this.

      The WordCandy Weekly email template.

      This makes it easy for us to add new content, subject lines, and preheaders each week without needing to recreate the look and layout each time. Building this template was also quite effortless. Almost all newsletter solutions will offer you both layouts and themes you can use as a basis for your campaigns.

      For example, Mailchimp offers various design options for free.

      A sample of several Mailchimp themes.

      One thing you’ll notice about these themes is that, while they feature very different looks and are designed for various purposes, they almost all prioritize simplicity. This is a key consideration when it comes time to design your template. While making your emails look compelling is necessary, what matters more is that the design doesn’t overwhelm or bury the actual content.

      You can see this philosophy applied in our newsletter as well, as we opted for a straightforward, accessible approach. We decided to only use a single image, as our primary goal is to highlight the featured news items. However, images can serve a variety of useful purposes, especially if you’re using your campaigns to highlight products or if your newsletter will have a more commercial focus. In the end, your template’s design should serve your ultimate goals.

      It’s also a smart idea to design with accessibility in mind. This includes making sure that color combinations and fonts are easy to read. What’s more, many email marketing solutions will let you send a version of your newsletter that strips out all images and styling. This is called a plain-text campaign. Mailchimp, like many similar tools, automatically generates a plain-text campaign and sends it to subscribers who have opted not to receive the standard HTML version of your emails.

      Once you’ve designed your template, it’s always critical to test it before going live. A simple way of doing this is by sending out test emails and getting feedback from your coworkers, friends, and so on. If you have created multiple templates, you can also perform A/B testing to see which one is most effective.

      2. Use Automation to Your Advantage

      To make the most out of your newsletter, you should aim to do as little work as possible. This may sound counterintuitive, but the point is that it’s vital to make your campaigns efficient. After all, consider how much time it would take to manually write and send every single email if you had to construct it all from scratch each time.

      Fortunately, any quality email marketing service will provide you with automation options. There are several ways you can use these to your advantage, but let’s look at a few of the most helpful strategies.

      First and foremost, you can set up your campaign to send full emails automatically, at specific trigger points. Jackmail refers to this as creating an automation or an automated workflow. A common example of this is to send a welcome email to new users, which triggers when they sign up to your site.

      However, you can get even more creative with this option. For instance, you could send a birthday congratulation email on each subscriber’s birthday and even include a coupon code as a gift. This adds a personal element to your newsletters.

      To elaborate further on that point, you should also aim to make sure every email feels like it’s directed at the recipient. A good way to achieve this is by using variables, which will be dynamically replaced with relevant information. In Mailchimp, these are referred to as Merge Tags, and you can use them in a variety of ways.

      One option that we implemented in our newsletter is the customizable date tag. When editing a new email, the date simply appears like this:

      The date merge tag in the Mailchimp editor.

      However, the system will automatically add the current date when the newsletter is generated.

      The current date in a sent newsletter.

      An even better use for merge tags is to display information that’s specific to each recipient. For example, if you collected their names during the registration process, you can add the *|FNAME|* tag to display each person’s first name in their email. This helps make each message seem less impersonal, even if they’re automated. In turn, this can help increase the number of clicks on your newsletters.

      3. Keep a Close Eye on Your Newsletter Statistics

      As your newsletter grows, it becomes crucial that you don’t get complacent. In fact, this is where your job really begins, as you’ll need to make sure that your campaigns are (and remain) effective. To do that, you’ll have to study and analyze your email analytics.

      Which metrics you should focus on will depend somewhat on your newsletter’s purpose. However, here are some of the main numbers you should look out for in all your emails:

      • Click Through Rate (CTR): This shows you how many recipients clicked on at least one link on a specific email.
      • Open rate: This is a percentage value displaying how many recipients opened your email at least once.
      • Subscriber growth: This lets you know how many new users have subscribed to your newsletter.

      Once you have this information, which should be provided by your email marketing solution, you can start to improve metrics that are sub-par. For example, you may find that your links are not clearly defined, making them less likely to be clicked on. Or perhaps your subject lines aren’t engaging enough, leading people to ignore your emails. If your subscriber count has plateaued, on the other hand, you might consider marketing your newsletter more on your website and social media.

      Finally, an effective way to get better results from your campaigns is to tailor them to a specific portion of your audience. This is known as audience segmentation, which means focusing unique campaigns on the users who most likely to be interested in them. Using segmentation in your newsletters enables you to raise your CTR and conversions, as subscribers will receive emails that are a better match to their demographics and interests.

      Push Send

      You might think that most people’s inboxes are too stuffed to fit in another newsletter, but you’d be mistaken. There’s always room for one more subscription, especially if it’s well-written, engaging, and provides genuine value to the reader. The best part is that sending out email campaigns will benefit both you and your subscribers.



      Source link

      Create a Salt Execution Module


      Updated by Linode Written by Linode

      Use promo code DOCS10 for $10 credit on a new account.

      A Salt execution module is a Python module that runs on a Salt minion. It perform tasks and returns data to the Salt master. In this tutorial you will create and install an execution module that will call the US National Weather Service API and return the current temperature at a specified weather station. This example could easily be adapted to access any API.

      Before You Begin

      If you haven’t already, set up a Salt master and at least one Salt minion. You can follow the first few steps of our Getting Started with Salt – Basic Installation and Setup guide.

      Note

      The steps in this guide require root privileges. Be sure to run the steps below with the sudo prefix. For more information on privileges, see our Users and Groups guide.

      Prepare Salt

      The files created in the following steps will be located in the /srv/salt directory. If you have changed Salt’s default file_roots configuration, use that directory location instead.

      1. Begin by creating the /srv/salt directory if it does not already exist. This is where you will place your top file and your Salt state file:

        mkdir /srv/salt
        
      2. Create a top file in /srv/salt which will be Salt’s point of entry for our Salt configuration:

        /srv/salt/top.sls
        1
        2
        3
        
        base:
          '*':
            - weather
      3. Create a state file named weather.sls and instruct Salt to make sure our minions have PIP installed, as well as the required Python library.

        /srv/salt/weather.sls
        1
        2
        3
        4
        5
        6
        7
        
        python-pip:
          pkg.installed
        
        requests:
          pip.installed:
            - require:
              - pkg: python-pip
      4. Apply these state changes:

        salt '*' state.apply
        
      5. Finally, create the /srv/salt/_modules directory which will contain our execution module:

        mkdir /srv/salt/_modules
        

      Create the Execution Module

      1. Create a file called weather.py in the /srv/salt/_modules directory, and add the following lines to set up Salt logging and import the requests module.

        /srv/salt/_modules/weather.py
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        
        import logging
        try:
            import requests
            HAS_REQUESTS = True
        except ImportError:
            HAS_REQUESTS = False
        
        log = logging.getLogger(__name__)
        
        . . .
      2. Add the __virtualname__ variable and the __virtual__ function.

        /srv/salt/_modules/weather.py
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
        
        . . .
        
        __virtualname__ = 'weather'
        
        def __virtual__():
            '''
            Only load weather if requests is available
            '''
            if HAS_REQUESTS:
                return __virtualname__
            else:
                return False, 'The weather module cannot be loaded: requests package unavailable.'
        
        . . .

        The __virtual__ function either returns the module’s virtual name and loads the module, or returns False with an error string and the module is not loaded. The if HAS_REQUESTS conditional is tied to the try/except block created in the previous step through the use of the HAS_REQUESTS variable.

      3. Add the public get() function and the private _make_request() function:

        /srv/salt/_modules/weather.py
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
        29
        30
        31
        
        . . .
        
        def get(signs=None):
            '''
            Gets the Current Weather
        
            CLI Example::
        
                salt minion weather.get KPHL
        
            This module also accepts multiple values in a comma separated list::
        
                salt minion weather.get KPHL,KACY
            '''
            log.debug(signs)
            return_value = {}
            signs = signs.split(',')
            for sign in signs:
                return_value[sign] = _make_request(sign)
            return return_value
        
        def _make_request(sign):
            '''
            The function that makes the request for weather data from the National Weather Service.
            '''
            request = requests.get('https://api.weather.gov/stations/{}/observations/current'.format(sign))
            conditions = {
                "description:": request.json()["properties"]["textDescription"],
                "temperature": round(request.json()["properties"]["temperature"]["value"], 1)
            }
            return conditions

        There are two functions in this step. The get() function accepts one or more weather station call signs as a comma separated list. It calls _make_request() to make the HTTP request and returns a text description of the current weather and the temperature.

        It’s important to note that by adding an underscore to the beginning of the _make_request() function it becomes a private function, which means it is not directly accessible through the Salt command line or a state file.

        The complete file looks like this:

        /srv/salt/_modules/weather.py
         1
         2
         3
         4
         5
         6
         7
         8
         9
        10
        11
        12
        13
        14
        15
        16
        17
        18
        19
        20
        21
        22
        23
        24
        25
        26
        27
        28
        29
        30
        31
        32
        33
        34
        35
        36
        37
        38
        39
        40
        41
        42
        43
        44
        45
        46
        47
        48
        49
        50
        
        import logging
        try:
            import requests
            HAS_REQUESTS = True
        except ImportError:
            HAS_REQUESTS = False
        
        log = logging.getLogger(__name__)
        
        __virtual_name__ = 'weather'
        
        def __virtual__():
            '''
            Only load weather if requests is available
            '''
            if HAS_REQUESTS:
                return __virtual_name__
            else:
                return False, 'The weather module cannot be loaded: requests package unavailable.'
        
        
        def get(signs=None):
            '''
            Gets the Current Weather
        
            CLI Example::
        
                salt minion weather.get KPHL
        
            This module also accepts multiple values in a comma seperated list::
        
                salt minion weather.get KPHL,KACY
            '''
            log.debug(signs)
            return_value = {}
            signs = signs.split(',')
            for sign in signs:
                return_value[sign] = _make_request(sign)
            return return_value
        
        def _make_request(sign):
            '''
            The function that makes the request for weather data from the National Weather Service.
            '''
            request = requests.get('https://api.weather.gov/stations/{}/observations/current'.format(sign))
            conditions = {
                "description:": request.json()["properties"]["textDescription"],
                "temperature": round(request.json()["properties"]["temperature"]["value"], 1)
            }
            return conditions

      Run the Execution Module

      1. To run the execution module, you need to first sync it to your minions. To do this, you can call a highstate with state.apply, which will also try to apply the state changes you specified earlier in the weather.sls state file. Since the weather.sls state was already applied in the Preparing Salt section, use the saltutil.sync_modules function:

        salt '*' saltutil.sync_modules
        
      2. Run the execution module on your Salt master:

        salt '*' weather.get KPHL
        

        You should see an output like the following:

          
        salt-minion:
        ----------
        KPHL:
            ----------
            description::
                Cloudy
            temperature:
                17.2
        
        
      3. Alternatively, you can run the Salt execution module locally on your Salt minion by entering the following:

        salt-call weather.get KVAY,KACY
        

        You should get an output like the following:

          
        local:
            ----------
            KACY:
                ----------
                description::
                    Cloudy
                temperature:
                    18.9
            KVAY:
                ----------
                description::
                    Cloudy
                temperature:
                    16.7
        
        

      You have now successfully created and installed a Salt execution module.

      More Information

      You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

      Join our Community

      Find answers, ask questions, and help others.

      This guide is published under a CC BY-ND 4.0 license.



      Source link

      How To Create an Image of Your Linux Environment and Launch It On DigitalOcean


      Introduction

      DigitalOcean’s Custom Images feature allows you to bring your custom Linux and Unix-like virtual disk images from an on-premise environment or another cloud platform to DigitalOcean and use them to start DigitalOcean Droplets.

      As described in the Custom Images documentation, the following image types are supported natively by the Custom Images upload tool:

      Although ISO format images aren’t officially supported, you can learn how to create and upload a compatible image using VirtualBox by following How to Create a DigitalOcean Droplet from an Ubuntu ISO Format Image.

      If you don’t already have a compatible image to upload to DigitalOcean, you can create and compress a disk image of your Unix-like or Linux system, provided it has the prerequisite software and drivers installed.

      We’ll begin by ensuring that our image meets the Custom Images requirements. To do this, we’ll configure the system and install some software prerequisites. Then, we’ll create the image using the dd command-line utility and compress it using gzip. Following that, we’ll upload this compressed image file to DigitalOcean Spaces, from which we can import it as a Custom Image. Finally, we’ll boot up a Droplet using the uploaded image.

      Prerequisites

      If possible, you should use one of the DigitalOcean-provided images as a base, or an official distribution-provided cloud image like Ubuntu Cloud. You can then install software and applications on top of this base image to bake a new image, using tools like Packer and VirtualBox. Many cloud providers and virtualization environments also provide tools to export virtual disks to one of the compatible formats listed above, so, if possible, you should use these to simplify the import process. In the cases where you need to manually create a disk image of your system, you can follow the instructions in this guide. Note that these instructions have only been tested with an Ubuntu 18.04 system, and steps may vary depending on your server’s OS and configuration.

      Before you begin with this tutorial, you should have the following available to you:

      • A Linux or Unix-like system that meets all of the requirements listed in the Custom Images product documentation. For example, your boot disk must have:

        • A max size of 100GB
        • An MBR or GPT partition table with a grub bootloader
        • VirtIO drivers installed
      • A non-root user with administrative privileges available to you on the system you’re imaging. To create a new user and grant it administrative privileges on Ubuntu 18.04, follow our Initial Server Setup with Ubuntu 18.04. To learn how to do this on Debian 9, consult Initial Server Setup with Debian 9.

      • An additional storage device used to store the disk image created in this guide, preferably as large as the disk being copied. This can be an attached block storage volume, an external USB drive, an additional physical disk, etc.

      • A DigitalOcean Space and the s3cmd file transfer utility configured for use with your Space. To learn how to create a Space, consult the Spaces Quickstart. To learn how set up s3cmd for use with your Space, consult the s3cmd 2.x Setup Guide.

      Step 1 — Installing Cloud-Init and Enabling SSH

      To begin, we will install the cloud-Init initialization package. Cloud-init is a set of scripts that runs at boot to configure certain cloud instance properties like default locale, hostname, SSH keys and network devices.

      Steps for installing cloud-init will vary depending on the operating system you have installed. In general, the cloud-init package should be available in your OS’s package manager, so if you’re not using a Debian-based distribution, you should substitute apt in the following steps with your distribution-specific package manager command.

      Installing cloud-init

      In this guide, we’ll use an Ubuntu 18.04 server and so will use apt to download and install the cloud-init package. Note that cloud-init may already be installed on your system (some Linux distributions install cloud-init by default). To check, log in to your server and run the following command:

      If you see the following output, cloud-init has already been installed on your server and you can continue on to configuring it for use with DigitalOcean:

      Output

      usage: /usr/bin/cloud-init [-h] [--version] [--file FILES] [--debug] [--force] {init,modules,single,query,dhclient-hook,features,analyze,devel,collect-logs,clean,status} ... /usr/bin/cloud-init: error: the following arguments are required: subcommand

      If instead you see the following, you need to install cloud-init:

      Output

      cloud-init: command not found

      To install cloud-init, update your package index and then install the package using apt:

      • sudo apt update
      • sudo apt install cloud-init

      Now that we've installed cloud-init, we'll configure it for use with DigitalOcean, ensuring that it uses the ConfigDrive datasource. Cloud-init datasources dictate how cloud-init will search for and update instance configuration and metadata. DigitalOcean Droplets use the ConfigDrive datasource, so we will check that it comes first in the list of datasources that cloud-init searches whenever the Droplet boots.

      Reconfiguring cloud-init

      By default, on Ubuntu 18.04, cloud-init configures itself to use the NoCloud datasource first. This will cause problems when running the image on DigitalOcean, so we need to reconfigure cloud-init to use the ConfigDrive datasource and ensure that cloud-init reruns when the image is launched on DigitalOcean.

      From the command line, navigate to the /etc/cloud/cloud.cfg.d directory:

      • cd /etc/cloud/cloud.cfg.d

      Use the ls command to list the cloud-init config files present in the directory:

      Output

      05_logging.cfg 50-curtin-networking.cfg 90_dpkg.cfg curtin-preserve-sources.cfg README

      Depending on your installation, some of these files may not be present. If present, delete the 50-curtin-networking.cfg file, which configures networking interfaces for your Ubuntu server. When the image is launched on DigitalOcean, cloud-init will run and reconfigure these interfaces automatically, so this file is not necessary. If this file is not deleted, the DigitalOcean Droplet created from this Ubuntu image will have its interfaces misconfigured and won't be accessible from the internet:

      • sudo rm 50-curtin-networking.cfg

      Next, we'll run dpkg-reconfigure cloud-init to remove the NoCloud datasource, ensuring that cloud-init searches for and finds the ConfigDrive datasource used on DigitalOcean:

      • sudo dpkg-reconfigure cloud-init

      You should see the following graphical menu:

      Cloud Init dpkg Menu

      The NoCloud datasource is initially highlighted. Press SPACE to unselect it, then hit ENTER.

      Finally, navigate to /etc/netplan:

      Remove the 50-cloud-init.yaml file, which was generated from the cloud-init networking file we removed previously:

      • sudo rm 50-cloud-init.yaml

      The final step is ensuring that we clean up configuration from the initial cloud-init run so that it reruns when the image is launched on DigitalOcean.

      To do this, run cloud-init clean:

      At this point you've installed and configured cloud-init for use with DigitalOcean. You can now move on to enabling SSH access to your droplet.

      Enable SSH Access

      Once you've installed and configured cloud-init, the next step is to ensure that you have a non-root admin user and password available to you on your machine, as outlined in the prerequisites. This step is essential to diagnose any errors that may arise after uploading your image and launching your Droplet. If a preexisting network configuration or bad cloud-init configuration renders your Droplet inaccesible over the network, you can use this user in combination with the DigitalOcean Droplet Console to access your system and diagnose any problems that may have surfaced.

      Once you've set up your non-root administrative user, the final step is to ensure that you have an SSH server installed and running. SSH often comes preinstalled on many popular Linux distributions. The process for checking whether a service is running will vary depending on your server's operating system.. If you aren't sure of how to do this, consult your OS's documentation on managing services. On Ubuntu, you can verify that SSH is up and running using the following command:

      You should see the following output:

      Output

      ● ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2018-10-22 19:59:38 UTC; 8 days 1h ago Docs: man:sshd(8) man:sshd_config(5) Process: 1092 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS) Main PID: 1115 (sshd) Tasks: 1 (limit: 4915) Memory: 9.7M CGroup: /system.slice/ssh.service └─1115 /usr/sbin/sshd -D

      If SSH isn't up and running, you can install it using apt (on Debian-based distributions):

      • sudo apt install openssh-server

      By default, the SSH server will start on boot unless configured otherwise. This is desirable when running the system in the cloud, as DigitalOcean can automatically copy in your public key and grant you immediate SSH access to your Droplet after creation.

      Once you've created a non-root administrative user, enabled SSH, and installed cloud-init, you're ready to move on to creating an image of your boot disk.

      Step 2 — Creating Disk Image

      In this step, we'll create a RAW format disk image using the dd command-line utility, and compress it using gzip. We'll then upload the image to DigitalOcean Spaces using s3cmd.

      To begin, log in to your server, and inspect the block device arrangement for your system using lsblk:

      You should see something like the following:

      Output

      NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT loop0 7:0 0 12.7M 1 loop /snap/amazon-ssm-agent/495 loop1 7:1 0 87.9M 1 loop /snap/core/5328 vda 252:0 0 25G 0 disk └─vda1 252:1 0 25G 0 part / vdb 252:16 0 420K 1 disk

      In this case, we notice that our main boot disk is /dev/vda, a 25GB disk, and the primary partition, mounted at /, is /dev/vda1. In most cases the disk containing the partition mounted at / will be the source disk to image. We are going to use dd to create an image of /dev/vda.

      At this point, you should decide where you want to store the disk image. One option is to attach another block storage device, preferably as large as the disk you are going to image. You can then save the image to this attached temporary disk and upload it to DigitalOcean Spaces.

      If you have physical access to the server, you can add an additional drive to the machine or attach another storage device, like an external USB disk.

      Another option, which we'll demonstrate in this guide, is copying the image over SSH to a local machine, from which you can upload it to Spaces.

      No matter which method you choose to follow, ensure that the storage device to which you save the compressed image has enough free space. If the disk you're imaging is mostly empty, you can expect the compressed image file to be significantly smaller than the original disk.

      Warning: Before running the following dd command, ensure that any critical applications have been stopped and your system is as quiet as possible. Copying an actively-used disk may result in some corrupted files, so be sure to halt any data-intensive operations and shut down as many running applications as possible.

      Option 1: Creating Image Locally

      The syntax for the dd command we're going to execute looks as follows:

      • dd if=/dev/vda bs=4M conv=sparse | pv -s 25G | gzip > /mnt/tmp_disk/ubuntu.gz

      In this case, we are selecting /dev/vda as the input disk to image, and setting the input/output block sizes to 4MB (from the default 512 bytes). This generally speeds things up a little bit. In addition, we are using the conv=sparse flag to minimize the output file size by skipping over empty space. To learn more about dd's parameters, consult the dd manpage.

      We then pipe the output to the pv pipe viewer utility so we can visually track the progress of the transfer (this pipe is optional, and requires installing pv using your package manager). If you know the size of the initial disk (in this case it's 25G), you can add the -s 25G to the pv pipe to get an ETA for when the transfer will complete.

      We then pipe it all to gzip, and save it in a file called ubuntu.gz on the temporary block storage volume we've attached to the server. Replace /mnt/tmp_disk with the path to the external storage device you've attached to your server.

      Option 2: Creating Image over SSH

      Instead of provisioning additional storage for your remote machine, you can also execute the copy over SSH if you have enough disk space available on your local machine. Note that depending on the bandwidth available to you, this can be slow and you may incur additional costs for data transfer over the network.

      To copy and compress the disk over SSH, execute the following command on your local machine:

      • ssh remote_user@your_server_ip "sudo dd if=/dev/vda bs=4M conv=sparse | gzip -1 -" | dd of=ubuntu.gz

      In this case, we are SSHing into our remote server, executing the dd command there, and piping the output to gzip. We then transfer the gzip output over the network and save it as ubuntu.gz locally. Ensure you have the dd utility available on your local machine before running this command:

      Output

      /bin/dd

      Create the compressed image file using either of the above methods. This may take several hours, depending on the size of the disk you're imaging and the method you're using to create the image.

      Once you've created the compressed image file, you can move on to uploading it to your DigitalOcean Spaces using s3cmd.

      Step 3 — Uploading Image to Spaces and Custom Images

      As described in the prerequisites, you should have s3cmd installed and configured for use with your DigitalOcean Space on the machine containing your compressed image.

      Locate the compressed image file, and upload it to your Space using s3cmd:

      Note: You should replace your_space_name with your Space’s name and not its URL. For example, if your Space’s URL is https://example-space-name.nyc3.digitaloceanspaces.com, then your Space’s name is example-space-name.

      • s3cmd put /path_to_image/ubuntu.gz s3://your_space_name

      Once the upload completes, navigate to your Space using the DigitalOcean Control Panel, and locate the image in the list of files. We will temporarily make the image publicly accessible so that Custom Images can access it and save a copy.

      At the right-hand side of the image listing, click the More drop down menu, then click into Manage Permissions:

      Spaces Object Configuration

      Then, click the radio button next to Public and hit Update to make the image publicly accessible.

      Warning: Your image will temporarily be publicly accessible to anyone with its Spaces path during this process. If you'd like to avoid making your image temporarily public, you can create your Custom Image using the DigitalOcean API. Be sure to set your image to Private using the above procedure after your image has successfully been transferred to Custom Images.

      Fetch the Spaces URL for your image by hovering over the image name in the Control Panel, and hit Copy URL in the window that pops up.

      Now, navigate to Images in the left hand navigation bar, and then Custom Images.

      From here, upload your image using this URL as detailed in the Custom Images Product Documentation.

      You can then create a Droplet from this image. Note that you need to add an SSH key to the Droplet on creation. To learn how to do this, consult How to Add SSH Keys to Droplets.

      Once your Droplet boots up, if you can SSH into it, you've successfully launched your Custom Image as a DigitalOcean Droplet.

      Debugging

      If you attempt to SSH into your Droplet and are unable to connect, ensure that your image meets the listed requirements and has both cloud-init and SSH installed and properly configured. If you still can't access the Droplet, you can attempt to use the DigitalOcean Droplet Console and the non-root user you created earlier to explore the system and debug your networking, cloud-init and SSH configurations. Another way of debugging your image is to use a virtualization tool like Virtualbox to boot up your disk image inside of a virtual machine, and debug your system's configuration from within the VM.

      Conclusion

      In this guide, you've learned how to create a disk image of an Ubuntu 18.04 system using the dd command line utility and upload it to DigitalOcean as a Custom Image from which you can launch Droplets.

      The steps in this guide may vary depending on your operating system, existing hardware, and kernel configuration but, in general, images created from popular Linux distributions should work using this method. Be sure to carefully follow the steps for installing and configuring cloud-init, and ensure that your system meets all the requirements listed in the [prerequisites](todo: link) section above.

      To learn more about Custom Images, consult the offical Custom Images product documentation.



      Source link